将水平线添加到 R 中 plotly 中的 hoverinfo 文本
Add horizontal line to hoverinfo text in plotly in R
有没有办法在 plotly hoverinfo 框上添加一条水平线?我想要一些看起来有点像的东西(线条,而不是盒子的其余部分),这是通过传单获得的。
我认为可以简单地添加 html 标签 <hr>
但它不起作用。
这是一个 RE,它也显示了我的尝试:
library(plotly)
set.seed(123)
dd <- data.frame(
xx = rnorm(10),
yy = rnorm(10),
ff = as.factor(c("a","b","c","a","b","c","a","a","b","c")),
ss = round(runif(10, 100,1000))
)
pp <- plot_ly(data = dd,
x = ~xx,
y = ~yy,
hoverinfo = 'text',
text = ~paste(ff,
'</br></hr>',
"</br>value:", ss,
'</br><hr>',
'</br><hr><hr/>',sep=""))
add_markers(pp,mode = "markers")
如下图所示,标签 <br>
被理解,但 <hr>
不被理解。
知道如何实现吗?
从这个help page开始,plotly
只支持部分HTML标签:
Plotly uses a subset of HTML tags to do things like newline (<br>),
bold (<b></b>), italics (<i>), and hyperlinks (<a href=’…’></a>). Tags <em>, <sup>, and <sub> are also supported.
你可以edit the plotly.js
file to add the missing tags. See var TAG_STYLES
in the source code.
我考虑过using LaTeX, but unfortunately, LaTex typesetting is currently broken。
有没有办法在 plotly hoverinfo 框上添加一条水平线?我想要一些看起来有点像的东西(线条,而不是盒子的其余部分),这是通过传单获得的。
我认为可以简单地添加 html 标签 <hr>
但它不起作用。
这是一个 RE,它也显示了我的尝试:
library(plotly)
set.seed(123)
dd <- data.frame(
xx = rnorm(10),
yy = rnorm(10),
ff = as.factor(c("a","b","c","a","b","c","a","a","b","c")),
ss = round(runif(10, 100,1000))
)
pp <- plot_ly(data = dd,
x = ~xx,
y = ~yy,
hoverinfo = 'text',
text = ~paste(ff,
'</br></hr>',
"</br>value:", ss,
'</br><hr>',
'</br><hr><hr/>',sep=""))
add_markers(pp,mode = "markers")
如下图所示,标签 <br>
被理解,但 <hr>
不被理解。
知道如何实现吗?
从这个help page开始,plotly
只支持部分HTML标签:
Plotly uses a subset of HTML tags to do things like newline (<br>), bold (<b></b>), italics (<i>), and hyperlinks (<a href=’…’></a>). Tags <em>, <sup>, and <sub> are also supported.
你可以edit the plotly.js
file to add the missing tags. See var TAG_STYLES
in the source code.
我考虑过using LaTeX, but unfortunately, LaTex typesetting is currently broken。