本文介绍了plotly + ggplot2:堆叠barplot中缺少一些工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 举例来说 library(ggplot2) library(绘图) df p ggplotly(p) Given for examplelibrary(ggplot2)library(plotly)df <- data.frame(V1=gl(6,20), V2=gl(40,3))p <- ggplot(df, aes(x=V1, fill=V2)) + geom_bar(color="white")ggplotly(p)some bar segments show no tooltip/hover information, whereas the legend displays the huge number of factor levels nicely (=scroll bar). How can I fix this?I'm usingpackageVersion("ggplot2")# [1] ‘2.2.0’packageVersion("plotly")# [1] ‘4.5.6’Edit/FYI: Crossposted to GitHub. 解决方案 adding some code. We can fix it:library(ggplot2)library(plotly)df <- data.frame(V1=gl(6,20), V2=gl(40,3))p <- ggplot(df, aes(x=V1, fill=V2)) + geom_bar(color="white")fixed<-ggplotly(p)for (i in 1:length(levels(df$V2))){ fixed$x$data[[i]]$text[length(fixed$x$data[[i]]$text)+1] <- c("")}fixed 这篇关于plotly + ggplot2:堆叠barplot中缺少一些工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-20 12:25
查看更多