R 如何使用重会话模型删除ggplot中的图例?
我想问一下如何用回归模型删除ggplot中的图例 我已经添加了elegend.position=None 但图例无法删除。你能告诉我我做错了什么吗 额外问题!! 在我当前的代码中,如何在N0和N1之间更改符号大小和形状?我想要更大尺寸的“开放圆”和“封闭正方形” 非常感谢R 如何使用重会话模型删除ggplot中的图例?,r,ggplot2,regression,R,Ggplot2,Regression,我想问一下如何用回归模型删除ggplot中的图例 我已经添加了elegend.position=None 但图例无法删除。你能告诉我我做错了什么吗 额外问题!! 在我当前的代码中,如何在N0和N1之间更改符号大小和形状?我想要更大尺寸的“开放圆”和“封闭正方形” 非常感谢 ggplot(data=x, aes(x=agw, y=pgw)) + geom_point (data=x, aes(x=agw, y=pgw, color=Nitrogen)) + stat_smooth(me
ggplot(data=x, aes(x=agw, y=pgw)) +
geom_point (data=x, aes(x=agw, y=pgw, color=Nitrogen)) +
stat_smooth(method = 'lm', se=FALSE, color="Black") +
scale_color_manual(values = c("Dark gray","Black")) +
theme(legend.position = "None") +
geom_text(x=30, y=70, label="", size=3.5, col="Black") +
geom_text(x=30, y=60, label="", size=3.5, col="Black") +
scale_x_continuous(breaks = seq(0,80,10),limits = c(0,80)) +
scale_y_continuous(breaks = seq(0,80,10), limits = c(0,80)) +
theme_bw() +
theme(panel.grid = element_blank())
这应该在缺乏可复制数据的情况下起作用。注意,像theme_bw这样的函数用于删除@Ronald提到的以前的主题设置。所以最好在情节的最后一部分加上。对于形状,您可以像这样在aes中启用形状,并使用scale_shape_manual格式化其中的数字属于您想要的形状:
library(ggplot2)
#Code
ggplot(data=x, aes(x=agw, y=pgw)) +
geom_point (data=x, aes(x=agw, y=pgw, color=Nitrogen,shape=Nitrogen,size=3)) +
stat_smooth(method = 'lm', se=FALSE, color="Black") +
scale_color_manual(values = c("Dark gray","Black")) +
scale_shape_manual(values = c(1,15))+
geom_text(x=30, y=70, label="", size=3.5, col="Black") +
geom_text(x=30, y=60, label="", size=3.5, col="Black") +
scale_x_continuous(breaks = seq(0,80,10),limits = c(0,80)) +
scale_y_continuous(breaks = seq(0,80,10), limits = c(0,80)) +
theme_bw() +
theme(panel.grid = element_blank(),
legend.position = 'none')
对于图例:在geom_点内添加参数show.legend=F。对于不同的点大小:您能给我们一个数据集的例子吗?我们可能需要重塑它
ggplot(data=x, aes(x=agw, y=pgw)) +
geom_point (data=x, aes(x=agw, y=pgw, color=Nitrogen), show.legend = F) +
stat_smooth(method = 'lm', se=FALSE, color="Black") +
scale_color_manual(values = c("Dark gray","Black")) +
theme(legend.position = "None") +
geom_text(x=30, y=70, label="", size=3.5, col="Black") +
geom_text(x=30, y=60, label="", size=3.5, col="Black") +
scale_x_continuous(breaks = seq(0,80,10),limits = c(0,80)) +
scale_y_continuous(breaks = seq(0,80,10), limits = c(0,80)) +
theme_bw() +
theme(panel.grid = element_blank())
将ThemeGend.position=None放在theme_bw之后。关于符号大小的问题不清楚。也许geom_pointaesx=agw,y=pgw,shape=n,size=5?我解决了!!!!!非常感谢!!罗兰:是的!!现在我完全明白了!!非常感谢!!你们是我的英雄!!!