legends orientation in ggvis

前端 未结 1 1353
耶瑟儿~
耶瑟儿~ 2020-12-21 08:50

In ggvis how to make legend vertical?

mtcars %>% ggvis(x = ~wt, y = ~mpg, fill = ~cyl) %>%
layer_points() %>%
add_legend(\"fill\",properties = legen         


        
相关标签:
1条回答
  • 2020-12-21 09:16

    Try the below code:

    mtcars %>% ggvis(~wt, ~mpg, size = ~cyl, fill = ~cyl) %>% layer_points() %>% add_legend(c("size", "fill"))
    

    Output chart:

    enter image description here

    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:

    enter image description here

    0 讨论(0)
提交回复
热议问题