我想在图表中创建一个图表,我将图例分组,但不是在图例中显示跟踪名称,而是只显示组名称。
我的代码如下:
p = plot_ly() %>%
layout(
font = list(family = "Arial"),
legend = list(x = 0.07, y = 1))
p = add_trace(p,
x = x,
y = y,
line = list(color = "blue", width=4),
legendgroup = "Average",
name = "Average",
type = "scatter",
mode = "lines+markers"
)
for (i in 1:ncol(df)){
p = add_trace(p,
x = x,
y = df[,i],
legendgroup = "Individual",
line = list(color = "gray"),
name = P_names[i],
type = "scatter",
mode = "lines+markers"
)
}
理想情况下,我想要的是一个传奇盒,只有:"平均"和"个人"。这可能吗?
谢谢!