有没有办法在多行上显示悬停文本/让它识别文本中的特殊字符行'\n'?
我正在寻找的虚拟版本是:
data <- data.frame(cbind(rnorm(10, 8), rnorm(10, 2)))
names(data)<-c("thing1", "thing2")
data$hovertext <- paste("here's a coordinate: ",
round(data$thing1,1), sep = "\n")
p <- plot_ly(data, type = 'scatter', x = thing1, y = thing2,
text = hovertext, hoverinfo = 'text', mode = "markers")
Run Code Online (Sandbox Code Playgroud)
这当然只是忽略了分隔符并在一行上打印.我可以通过剧情/ R来识别断行吗?
Mar*_*zer 41
只需使用HTML标记<br>:
library(plotly)
data <- data.frame(cbind(rnorm(10, 8), rnorm(10, 2)))
names(data) <- c("thing1", "thing2")
data$hovertext <- paste("here's a coordinate:",
round(data$thing1,1), sep = "<br>")
p <- plot_ly(data, type = 'scatter', x = ~thing1, y = ~thing2,
text = ~hovertext, hoverinfo = 'text', mode = "markers")
Run Code Online (Sandbox Code Playgroud)
此外,您还可以使用HTML标签来更改字体样式(以及更多)...