【问题标题】:renderPlotly Hide ggplot2 line by defaultrenderPlotly 默认隐藏 ggplot2 行
【发布时间】:2018-01-11 04:54:20
【问题描述】:
library(plotly)

dat1 <- data.frame(
sex = factor(c("Female","Female","Male","Male")),
time = factor(c("Lunch","Dinner","Lunch","Dinner"), levels=c("Lunch","Dinner")),
total_bill = c(13.53, 16.81, 16.24, 17.42)
)

p <- ggplot(data=dat1, aes(x=time, y=total_bill, group=sex,color=sex)) +
geom_line() +
geom_point()

ggplotly(p)

我想默认隐藏一行,以便用户可以随时单击它并使其在绘图本身上可见。 我正在使用“renderPlotly”以闪亮的方式渲染上面的图。 我在这里缺少任何选项吗?

【问题讨论】:

    标签: r ggplot2 ggplotly


    【解决方案1】:

    添加以下行解决了这个问题。

    style(ggplotly(p),visible="legendonly", traces = 1)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-30
      • 2021-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多