【发布时间】:2017-02-08 05:36:02
【问题描述】:
我使用 ggplot 有一段时间了,直到我遇到了 Plotly 库并开始将它用于我的绘图。我仍然使用 ggplot 函数来创建绘图,最后使用 ggplotly 函数对其进行转换。
我在绘图中使用 geom_tile 和 geom_text 图层来创建热图。我将 geom_tile 中的“text”属性设置为要在工具提示中显示的文本,并在 ggplotly 函数中传递 tooltip="text"。我想在矩形内显示的文本是 geom_text 层中使用“label”属性设置的文本。
当绘图被渲染时,我可以分别看到两个工具提示,一个是我在 geom_tile 的 text 属性中设置的文本,另一个是在 geom_text 层的 label 属性中重复文本。
我怎样才能摆脱最后一个工具提示?
提前致谢!
这是我的代码:
gg<-ggplot(dataframe, aes(x=varX,y=varY))+
geom_tile(aes(fill=cm,text=paste("#",casos)))+
geom_text(aes(label=cm,size=casos),family = "arial", color="#111111")+
scale_fill_gradient2(low="#DD3333",mid="#EEEE99",high="#00AA00")+
labs(x="varX",y="varY",fill="CM")+ scale_size(range = c(2.5, 5),guide='none') +
theme(text=element_text(family = "arial", color="#666666", size=11) ,title=element_text(family = "arial", color="#666666", face="bold", size=12), axis.text=element_text(family = "arial", color="#666666", size=9),axis.text.x=element_text(angle=330))
ggplotly(gg, tooltip="text")
【问题讨论】: