4

How do you spread a legend over multiple columns in ggplotly?

The answer here makes it obvious how to do so using ggplot() - however that code doesn't seem to work when I use ggplotly()

library(datasets)
library(ggplot2)
library(plotly)

p<-ggplot(mtcars, aes(x=mpg,y=cyl)) + geom_point(aes(col=row.names(mtcars)))
p
ggplotly(p)
p2<-p + guides(col=guide_legend(ncol=3))
p2 # here we see the legend with 3 column
ggplotly(p2) # here we see the legend with only 1 column
Community
  • 1
  • 1
val
  • 1,629
  • 1
  • 30
  • 56

0 Answers0