Black Lives Matter. Please consider donating to Black Girls Code today.

Ggplotly config autosize issues

I’m pushing a ggplot2 graph to plotly using config options to remove the Mode Bar and autosize = T. In R, when I run the following code:

d<- ggplot(c, aes(Var1, Freq)) + geom_bar(stat=“identity”) +xlab("")+ ylab("") + ggtitle(“Title”) + scale_x_date()
d

Everything looks perfect in the window as a static graph.
When I run this using ggplotly:

ggplotly(d) %>% config(displayModeBar = F, autosize=T)
I get the following:

The graph is no longer filling the window even while setting autosize = T. Although modebar=F and the x axis scale are working fine.

when I push this to plotly using

api_create(d)

I get this graph which still is not filling the window (autosize), but now the modebar is back and the x axis has turned numeric.

Any idea what is going on here?
Thanks!

1 Like

Even I am facing the same issues. I have deployed the ggplot2-plotly combination in shiny but its not expanding anymore.
I am also looking for some help regarding this. If you have figured out something please share then.
Plotly does not autosize the ggplot2 charts.

Same issue here. I upgraded plotly to v. 4.7.0 today and suddenly this problem appeared, so there is probably something in that update that is causing this. Any help would be appreciated.

1 Like