英文:
How to remove graph showing in the range slider?
问题
我正在开发一个R Shiny仪表板,并使用范围滑块,但我不喜欢滑块中显示图表的重复 - 如何移除它?
我刚刚发送了来自plotly信息页面的链接,以说明我的意思:
我已经创建了这个:
xaxis_plots[["rangeslider"]] <- list(range="week_ending", visible = TRUE, thickness = 0.05, bgcolor = "#ECEBF3")
然而,当我将它添加到plotly代码中时,它仍然显示图表内部。
英文:
I am developing a R Shiny dashboard and making use of the range slider, however I do not like the repeat of the chart showing in the slider - how do I remove this?
I have just sent the link from the plotly info page to show what I mean:
I have created this:
xaxis_plots[["rangeslider"]] <- list(range="week_ending", visible = TRUE, thickness = 0.05, bgcolor = "#ECEBF3")
However, it still shows the chart inside when I add it to plotly code.
答案1
得分: 0
这是一种方法。我们绘制了两倍于该系列的一条线,但是它是不可见的,并且我们为这个系列添加了范围滑块。然后,我们在第二个x轴上绘制了第二个系列。
library(plotly)
plot_ly() %>%
add_lines(x = time(USAccDeaths), y = USAccDeaths, xaxis = "x2") %>%
add_lines(x = time(USAccDeaths), y = USAccDeaths, visible = FALSE) %>%
layout(
xaxis = list(rangeslider = list(visible = TRUE)),
xaxis2 = list(matches = "x", overlaying = "x")
)
<details>
<summary>英文:</summary>
Here is a way. We plot two times the series. One invisibly and we add the range slider for this series. Then we plot the second series on a second x-axis.
```r
library(plotly)
plot_ly() %>%
add_lines(x = time(USAccDeaths), y = USAccDeaths, xaxis = "x2") %>%
add_lines(x = time(USAccDeaths), y = USAccDeaths, visible = FALSE) %>%
layout(
xaxis = list(rangeslider = list(visible = TRUE)),
xaxis2 = list(matches = "x", overlaying = "x")
)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论