1
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”以闪亮的方式渲染上面的图。我在这里缺少任何选项吗?

4

1 回答 1

1

添加以下行解决了该问题。

style(ggplotly(p),visible="legendonly", traces = 1)
于 2018-01-11T05:09:54.320 回答