I would like to have two side by side plots sharing the same X-axis and the same toolbar. This means that, by zooming in the first plot, the second plot should automatically resize to the same zoomed region.
A way to do that could be to stack the plots one above the other, using shareX=TRUE
, but I need them to be side by side.
In python there seems to be a way to do that, using fig.update_xaxes(matches='x')
. Is there a similar option in R?
Here is a sample code:
library(plotly)
n = 10
x = 1:n
y = rnorm(n)
fig1 <- plot_ly(x = x, y = y, type = 'scatter', mode = 'lines+markers')
fig2 <- plot_ly(x = x, y = y, type = 'scatter', mode = 'lines+markers')
fig <- subplot(fig1, fig2, shareX = TRUE) # shareX actually not working here
fig
Thank you in advance!