I would like to change the default position of the legend in a ggvis
plot.
library(ggvis)
data(mtcars)
mtcars %>%
ggvis(x=~wt, y = ~mpg, fill = ~cyl) %>%
layer_points()
By default, the legend is on the right side. How to put it on the top?
With ggplot
you can achieve this simply but I could not find any similar way to do the same with ggvis
.
library(ggplot2)
mtcars %>%
ggplot(aes(x=wt, y=mpg, fill=cyl)) +
geom_point() +
theme(legend.position = 'top')
This thread suggests that up until now you cannot change the orientation of the legend, but is it true for the position as well?
Look at
?add_legend
and?legend_props
. I don't think you can doposition=top
etc, but you could use the x and y ranges of the data to position the legend exactly at the mid-top like withposition='top'
inggplot()
.