在使用ggplotly时,将鼠标移到标签上进行格式化 [英] Formatting mouse over labels in plotly when using ggplotly
本文介绍了在使用ggplotly时,将鼠标移到标签上进行格式化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 ggplotly
和鼠标悬停功能时,我正在使用文本格式。
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))
我想要一些格式化文本或至少换行我的鼠标在标签上。是否有关于如何设计这个鼠标而不是泡沫的好文档?
c $ c>可以使用换行HTML标记。您可以使用< br>
标签换行: (a)(文字= sprintf(字母:%s< br>字母:%s,a,b)c $ c> g < - ggplot(df,aes(x,y))+ geom_point ))
(gg < - ggplotly(g))
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\nLetter: %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
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时,将鼠标移到标签上进行格式化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文