【问题标题】:One slider to control graphs in single subplot in R using plotly一个滑块可使用 plotly 控制 R 中单个子图中的图形
【发布时间】:2019-11-01 00:23:10
【问题描述】:

我正在使用 R 在 plotly 中寻找范围选择器的某些修复。 我有两个使用 R 中的 Plotly 通过单个子图可视化的图。现在,我需要将一个范围滑块/选择器添加到完整的图中,以便更改它会修改我的两个图。 是否可以通过Plotly? (仅使用 R) 此功能类似于 Dygraphs 同步功能(https://rstudio.github.io/dygraphs/gallery-synchronization.html)。

【问题讨论】:

    标签: r plotly dygraphs r-plotly


    【解决方案1】:

    我建议使用subplots 选项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
    

    【讨论】:

    • 对于未来的读者:在this post 的底部,您可以找到使用范围滑块的相关方法。
    猜你喜欢
    • 2020-03-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-04
    • 2018-01-16
    • 2020-09-16
    • 1970-01-01
    • 2020-08-27
    • 2019-01-26
    相关资源
    最近更新 更多