使用ggplotly时在plotly中格式化鼠标在标签上 [英] Formatting mouse over labels in plotly when using ggplotly
本文介绍了使用ggplotly时在plotly中格式化鼠标在标签上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在使用 ggplotly
和鼠标悬停功能时,我在文本格式方面遇到了困难.
I am struggling with text formatting when using ggplotly
and the mouse over functionality.
library(plotly)
df <- data.frame(a=letters, b=LETTERS, x=runif(26), y=runif(26))
g <- ggplot(df, aes(x,y)) + geom_point(aes(text=sprintf('letter: %s
Letter: %s', a, b)))
g
(gg <- ggplotly(g))
我想在我的鼠标悬停标签上有一些格式化的文本或至少一个换行符.有没有关于如何设计这个鼠标悬停在气泡上的好文档?
I would like to have some formatted text or at least a newline in my mouse over label. Is there a good documentation on how to design this mouse over bubble thing?
推荐答案
plotly
可以使用换行HTML标签.使用 <br>
标签作为换行符后,您可以获得您的内容:
plotly
can make use of the line break HTML tag. You can get what your after using the <br>
tag for a newline:
g <- ggplot(df, aes(x,y)) +
geom_point(aes(text=sprintf("letter: %s<br>Letter: %s", a, b)))
(gg <- ggplotly(g))
这篇关于使用ggplotly时在plotly中格式化鼠标在标签上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文