一个用于使用R绘制的R控制单个子图中图形的滑块

问题描述 投票:0回答:1

我正在使用R绘图选择范围选择器。我使用R中的Plotly通过单个子图可视化了两个图。现在,我需要向整个图添加一个Range Slider / Selector,以便对其进行更改可以修改我的两个图。是否可以通过Plotly? (仅使用R)此功能类似于Dygraphs同步功能(https://rstudio.github.io/dygraphs/gallery-synchronization.html)。

r plotly dygraphs r-plotly
1个回答
0
投票

我建议使用subplot的选项shareX = TRUE

请检查以下示例:

library(plotly)

DF1 <- data.frame(x=1:100, y=runif(100)+ seq(0, 1, length.out = 100))
DF2 <- data.frame(x=1:100, y=runif(100)+ seq(0, 2, length.out = 100))

p1 <- plot_ly(DF1, x = ~x, y = ~y, type = "scatter", mode = "lines+markers")
p2 <- plot_ly(DF2, x = ~x, y = ~y, type = "scatter", mode = "lines+markers")

p <- subplot(p1, p2, nrows = 2, shareX = TRUE)
p

Result

© www.soinside.com 2019 - 2024. All rights reserved.