admin管理员组文章数量:1402287
Have a look at the following plot:
library(plotly)
pd <- structure(list(x = c(11, 12, 13, 11, 12, 13), variable = structure(c(
1L,
1L, 1L, 2L, 2L, 2L
), levels = c(
"veryveryveryveryveryverylongname1",
"veryveryveryveryveryverylongname2"
), class = "factor"), value = c(
1,
2, 3, 4, 3, 2
)), row.names = c(NA, -6L), class = "data.frame")
pd
plot_ly(pd, x=~x, y=~value, color=~variable) |>
layout(list(hoverlabel=list(namelength=-1L)))
Which produces this plot:
Problem: The hover label only shows veryveryvery...
so it is not easy to see from which trace it came. (I can use the color as a hint and look at the legend, but in case there are many traces the full name would be better.)
On this website I found that the approach layout(list(hoverlabel=list(namelength=-1L)))
should work, but it has no effect.
What am I doing wrong? Is there another approach?
Have a look at the following plot:
library(plotly)
pd <- structure(list(x = c(11, 12, 13, 11, 12, 13), variable = structure(c(
1L,
1L, 1L, 2L, 2L, 2L
), levels = c(
"veryveryveryveryveryverylongname1",
"veryveryveryveryveryverylongname2"
), class = "factor"), value = c(
1,
2, 3, 4, 3, 2
)), row.names = c(NA, -6L), class = "data.frame")
pd
plot_ly(pd, x=~x, y=~value, color=~variable) |>
layout(list(hoverlabel=list(namelength=-1L)))
Which produces this plot:
Problem: The hover label only shows veryveryvery...
so it is not easy to see from which trace it came. (I can use the color as a hint and look at the legend, but in case there are many traces the full name would be better.)
On this website https://community.plotly/t/how-to-display-the-whole-signal-name-with-the-hover-mode-is-x/47687 I found that the approach layout(list(hoverlabel=list(namelength=-1L)))
should work, but it has no effect.
What am I doing wrong? Is there another approach?
Share Improve this question edited Mar 21 at 14:24 EricLavault 16.1k3 gold badges27 silver badges56 bronze badges asked Mar 21 at 12:49 NoskarioNoskario 6764 silver badges19 bronze badges1 Answer
Reset to default 3You almost have it.
All you to do is remove the outermost list()
inside layout()
.
For completeness, the R reference documentation describes the namelength
here.
plot_ly(pd, x = ~ x, y = ~ value, color = ~ variable) |>
layout(hoverlabel = list(namelength = -1L))
本文标签: How do I make that the whole trace name in R plotly plot is shownStack Overflow
版权声明:本文标题:How do I make that the whole trace name in R plotly plot is shown? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744352784a2602151.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论