【问题标题】:ggplotly removes legend from ggplotggplotly 从 ggplot 中删除图例
【发布时间】:2016-04-09 07:31:06
【问题描述】:

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.

任何想法如何找回传说?

我正在使用 plotly_2.0.19 和 ggplot2_2.0.0.9000。

【问题讨论】:

    标签: r ggplot2 plotly


    【解决方案1】:

    出于某种原因,ggplotly 从未为geom_line 添加图例。当还添加点时,文档只有图例。我建议使用透明点作为解决方法。

    { ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
      geom_line() +
      geom_point(alpha = 0) } %>%
      ggplotly()
    

    【讨论】:

      猜你喜欢
      • 2021-06-06
      • 2021-12-16
      • 1970-01-01
      • 2020-11-03
      • 1970-01-01
      • 1970-01-01
      • 2016-06-07
      • 1970-01-01
      相关资源
      最近更新 更多