如何移除在范围滑块中显示的图表?

huangapple go评论58阅读模式
英文:

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:

chart

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() %&gt;%
  add_lines(x = time(USAccDeaths), y = USAccDeaths, xaxis = &quot;x2&quot;) %&gt;%
  add_lines(x = time(USAccDeaths), y = USAccDeaths, visible = FALSE) %&gt;%
  layout(
      xaxis = list(rangeslider = list(visible = TRUE)),
      xaxis2 = list(matches = &quot;x&quot;, overlaying = &quot;x&quot;)
  )

如何移除在范围滑块中显示的图表?

huangapple
  • 本文由 发表于 2023年5月6日 17:00:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76188027.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定