Try the below code:
mtcars %>% ggvis(~wt, ~mpg, size = ~cyl, fill = ~cyl) %>% layer_points() %>% add_legend(c("size", "fill"))
Output chart:
Hope this helps.
Edit:
I explored the add_legend
properties and unfortunately I do not see any way of achieving vertical continues scale legend using ggvis
for now, however it can be achieved using ggplot2
.
R code:
ggplot(mtcars, aes(wt, mpg, color = cyl))+geom_point()
Output chart:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…