gpt4 book ai didi

r - ggplotly 从 ggplot 中删除图例

转载 作者:行者123 更新时间:2023-12-05 00:57:24 27 4
gpt4 key购买 nike

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。

最佳答案

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

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

enter image description here

关于r - ggplotly 从 ggplot 中删除图例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34612286/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com