Code:
mtcars %>% group_by(cyl,am) %>% ggvis(~mpg, fill = ~factor(cyl)) %>% layer_densities()
The code above plots density graphs for each group of "cyl" and assigns different colors according to three levels of cyl
: (4,6,8). But I don't have control over what color is assigned to each group.
How can I assign specific colors e.g. "red", "green", and "yellow" to each group?
You can add the following to your ggvis
function
... %>% scale_ordinal("fill", range = c("red", "green", "yellow"))