在R中以plotly方式将水平线添加到hoverinfo文本中

时间:2018-03-01 19:50:43

标签: r plotly r-plotly

有没有办法在plotly hoverinfo框中添加水平线?我想要的东西看起来有点像(线条,而不是盒子的其余部分),这是用传单获得的。

enter image description here

我认为可以简单地添加html标记public class Subscriber1 { public Subscriber1(Shape shape) { shape.ColorChanged += new EventHandler(OnColorChanged); } void OnColorChanged(object sender, EventArgs e) { // this subscriber wants to get notified only if color changes to green, yellow and red } } public class Subscriber2 { public Subscriber2(Shape shape) { shape.ColorChanged += new EventHandler(OnColorChanged); } void OnColorChanged(object sender, EventArgs e) { // this subscriber wants to get notified only if color changes to red } } public class Subscriber3 { public Subscriber3(Shape shape) { shape.ColorChanged += new EventHandler(OnColorChanged); } void OnColorChanged(object sender, EventArgs e) { // this subscriber wants to get notified every time shape color changes } } ,但它不起作用。

这是一个RE,它也展示了我的尝试:

<hr>

如下图所示,标识为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>

enter image description here

知道如何实现这个目标吗?

1 个答案:

答案 0 :(得分:1)

help page开始,plotly仅支持一些HTML代码:

  

Plotly使用HTML标记的子集来执行换行(&lt; br&gt;)之类的操作,   粗体(&lt; b&gt;&lt; / b&gt;),斜体(&lt; i&gt;)和超链接(&lt; a href ='...'&gt;&lt; / a&gt;)。标签&lt; em&gt;,&lt; sup&gt;和&lt; sub&gt;也支持。

您可以edit the plotly.js file添加缺少的标签。请参阅source code中的var TAG_STYLES

我考虑了using LaTeX,但不幸的是,LaTex排版is currently broken