为什么ggplotly的参数工具提示不排序?

时间:2019-05-29 00:11:08

标签: r ggplot2 tooltip ggplotly

tooltip参数是一个向量,用于指定要在工具提示中显示的美学映射,并且应该以与您在代码中编写变量的方式相同的方式显示和排序变量,但至少对我而言不是。

我在github的问题页面上看到了相同的问题:

https://github.com/ropensci/plotly/issues/849

但是还没有解决。

p <- ggplot(data = iris, aes(x = Petal.Width, y = Sepal.Length, color = Species)) +
  geom_point()

ggplotly(p, tooltip = c("y", "colour", "x"))

出现在工具提示上的顺序是(“ x”,“ y”,“颜色”) 而不是代码中的那个(“ y”,“ colour”,“ x”)

1 个答案:

答案 0 :(得分:0)

我知道这是一个旧帖子,但以防万一其他人像我一样遇到这个问题。您是否尝试过这种带有工具提示的屏蔽方法?

#ordering
p <- ggplot(data = iris, aes(x = Petal.Width, y = Sepal.Length, color = Species, 
text = paste("y: ",y,"</br>colour: ",colour,"</br>x: ",x)) ) +
geom_point()

#mask everything else and only show what's in "text" variable
ggplotly(p, tooltip = c("text")) 
相关问题