gpt4 book ai didi

从图例中删除错误栏(ggplot2)

转载 作者:行者123 更新时间:2023-12-02 02:19:32 25 4
gpt4 key购买 nike

我使用以下命令绘制了一个绘图:

ggplot(data=test_mod, aes(x=realDist , y=1-value, color=as.factor(foo) , size=as.factor(foo) )) +
stat_summary(fun.y=mean, geom="line", alpha=0.85 ) +
stat_summary(fun.y=mean, geom="point", pch=21, fill="white", size=2 ) +
#stat_summary(fun.data=mean_cl_normal, geom="errorbar", width=8, size = 0.5) +
theme_bw(base_size = 15, base_family = "Palatino") +
theme(legend.key = element_blank())

我得到了这个传说:

enter image description here

但是,当我取消注释该命令的第 3 行时:

ggplot(data=test_mod, aes(x=realDist , y=1-value, color=as.factor(foo) , size=as.factor(foo) )) +
stat_summary(fun.y=mean, geom="line", alpha=0.85 ) +
stat_summary(fun.y=mean, geom="point", pch=21, fill="white", size=2 ) +
stat_summary(fun.data=mean_cl_normal, geom="errorbar", width=8, size = 0.5) +
theme_bw(base_size = 15, base_family = "Palatino") +
theme(legend.key = element_blank())

我得到的图例略有不同:

enter image description here

请注意在我开始在绘图中使用errorbar后穿过点的细线

如何消除图例中出现的那些细线?

最佳答案

您可以使用 show_guide=FALSE 关闭该元素的图例。 show.legend=FALSE

ggplot(data=test_mod, aes(x=realDist , y=1-value, color=as.factor(foo) , size=as.factor(foo) )) +
stat_summary(fun.y=mean, geom="line", alpha=0.85 ) +
stat_summary(fun.y=mean, geom="point", pch=21, fill="white", size=2 ) +
stat_summary(fun.data=mean_cl_normal, geom="errorbar", width=8, size = 0.5, show.legend=FALSE) +
theme_bw(base_size = 15, base_family = "Palatino") +
theme(legend.key = element_blank())

关于从图例中删除错误栏(ggplot2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31371106/

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