Orientation of legends in ggvis

In ggvis, how do I make the legend vertical?

mtcars %>% ggvis(x = ~wt, y = ~mpg, fill = ~cyl) %>%
layer_points() %>%
add_legend("fill",properties = legend_props( legend = list(x = 500, y = 50)))

      

He puts legends horizontally. I want it to be vertical.

+3


source to share


1 answer


Try the below code:

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

      

Output scheme:

enter image description here

Hope it helps.

Edit:



I've looked into the properties add_legend

and unfortunately don't see a way to achieve a vertical scale legend using ggvis

, however, it can be achieved with ggplot2

.

R-code:

ggplot(mtcars, aes(wt, mpg, color = cyl))+geom_point()

      

Output scheme:

enter image description here

+3


source







All Articles