Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想用它ggvis来实现这个类似问题所回答的问题:R中的按因子着色图
ggvis
以mtcars数据集为例,取自图层:分组:
mtcars
data(mtcars) mtcars %>% dplyr::mutate(cyl2 = factor(cyl)) %>% ggvis(~wt, ~mpg, stroke = ~cyl2) %>% layer_lines()
生产
使用由 给出的默认因子颜色stroke = ~cyl2。
stroke = ~cyl2
如何更改这些默认颜色?
只需添加笔画比例:
... %>% scale_ordinal("stroke", range = c("red", "green", "blue"))
也适用于十六进制表示!
... %>% scale_ordinal("stroke", range = c("#fc8d59", "#aaaaaa", "#99d594"))