如何更改ggvis中的配色方案?

时间:2016-09-29 22:26:41

标签: r ggvis

我想将调色板更改为两种任意HEX颜色。我怎么能在下面的图表中做到这一点?

hec <- as.data.frame(xtabs(Freq ~ Hair + Eye, HairEyeColor))

hec %>% 
  ggvis(~Hair, ~Eye, fill = ~Freq) %>% 
  layer_rects(width = band(), height = band()) %>%
  scale_nominal("x", padding = 0, points = FALSE) %>%
  scale_nominal("y", padding = 0, points = FALSE)

1 个答案:

答案 0 :(得分:2)

您需要在range中设置scale_numeric以更改连续填充渐变的开始和结束。

例如,如果您想要一系列红色到绿色,则可以使用

scale_numeric("fill", range = c("red", "green"))
相关问题