我想要两个并排的图表共享相同的X轴和工具栏。这意味着,通过在第一个图表中缩放,第二个图表应自动调整为相同的缩放区域。
一种方法是将图表堆叠在一起,使用“shareX=TRUE”,但我需要它们并排放置。
在Python中,似乎有一种方法可以做到这一点,使用“fig.update_xaxes(matches='x')”。R中是否有类似的选项?
以下是示例代码:
一种方法是将图表堆叠在一起,使用“shareX=TRUE”,但我需要它们并排放置。
在Python中,似乎有一种方法可以做到这一点,使用“fig.update_xaxes(matches='x')”。R中是否有类似的选项?
以下是示例代码:
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!