[英]R plotly specifying custom legend name with color parameter
I am trying to plot using color coding on a value, and changing default legend names. 我试图在值上使用颜色编码,并更改默认图例名称。 Can't seem to get it to work. 似乎无法让它发挥作用。
This code plots what I mainly want: 这段代码描绘了我主要想要的东西:
df <- data.frame(x = 1:10, y = 1:10)
plot_ly(df, x = x, y = y, color = y > 5, mode = 'markers')
Now, I am trying to change the default legend names so they are more explanatory: 现在,我正在尝试更改默认图例名称,以便它们更具说明性:
plot_ly(df, x = x, y = y, color = y > 5, mode = 'markers', name = c('Y <= 5', 'y > 5'))
Does not do anything, even though plotly documentation says name is the right way to change the legend name. 什么都不做,即使情节文件说明名称是更改图例名称的正确方法。
I just want the legend names to be more descriptive than simple true
and false
as they are shown in the plot. 我只是想传说的名字比简单的更具描述性的true
和false
,因为它们在图中显示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.