I do have a problem with plotly
package. The legend does not display correctly or does not show all the values cause it is cut!
I would like to get the legend outside of the plot area (at the bottom or right corner).
I have already tried to change the position in ggplot
:
legend.position="bottom"
no result at all...
then i have tried code from plotly
website:
p %>% layout(legend = list(x = 0.5, y = -100))
it did not work, the legend was at the bottom, but it was cut, and behind x axis title...
Here is a sample code from mtcars
dataset:
a <- ggplot(mtcars, aes(x = interaction(cyl, carb, lex.order = T), y = mpg,fill = interaction(cyl, carb, lex.order = T))) +
geom_boxplot()
ggplotly(a)
as we can see the title of the legend is cut there as well..
I would appreciate any help!
Thanks
You could play with the margin and plot size. You can try:
m = list(
l = 100,
r = 40,
b = 100,
t = 50,
pad = 0
)
a <- ggplot(mtcars, aes(x = interaction(cyl, carb, lex.order = T), y = mpg,fill = interaction(cyl, carb, lex.order = T))) +
geom_boxplot()
a %>% layout(autosize = F, width = 800, height = 600, margin = m)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With