I have a problem with the plotly package. The legend does not display correctly or does not display all the values caused by its slice!

I would like to get a legend outside the plot area (in the bottom or right corner).
I already tried changing position in ggplot :
legend.position="bottom"
no result at all ...
then I tried the code from plotly :
p %>% layout(legend = list(x = 0.5, y = -100))
it didn’t work, the legend was at the bottom, but it was cut out, and behind the name of the x axis ...
Here is a sample code from the mtcars :
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 that the name of the legend is also cut there.
I would be grateful for any help!
thanks
source share