ggplotly使用ggplot删除geom_line图的图例.
见下图:
library(plotly)
g <- ggplot(iris)
g = g + geom_line(aes(x = Sepal.Length, y = Sepal.Width, color = Species), size = 0.05)
g # Here is a legend
(gg <- ggplotly(g)) # Legend has now been removed.
Run Code Online (Sandbox Code Playgroud)
任何想法如何取回传奇?
我使用的是plotly_2.0.19和ggplot2_2.0.0.9000.
出于某种原因,ggplotly永远不会添加传奇geom_line.只有在添加点时,文档才有图例.我建议使用透明点作为解决方法.
{ ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_line() +
geom_point(alpha = 0) } %>%
ggplotly()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1176 次 |
| 最近记录: |