R(ggplot2):理解aes中使用形状或颜色时的不同行为()
下面是一个图:R(ggplot2):理解aes中使用形状或颜色时的不同行为(),r,ggplot2,R,Ggplot2,下面是一个图: ggplot(data.and.factors.prov,aes(x=Design.Complexity,y=FP,shape=factor(All.interactions))) + stat_summary(fun.data=mean_cl_normal,position=position_dodge(width=0.5)) + geom_blank() + geom_smooth(method='lm',se=F,formula=y~x,c
ggplot(data.and.factors.prov,aes(x=Design.Complexity,y=FP,shape=factor(All.interactions))) +
stat_summary(fun.data=mean_cl_normal,position=position_dodge(width=0.5)) +
geom_blank() +
geom_smooth(method='lm',se=F,formula=y~x,colour='black') +
scale_shape_manual(values=c(17,3,16,6,15,4),
name='Interactions',
labels=c('No interactions','All possible interactions','Randomly picked interactions\nand direct effects')) +
labs(x='Design.complexity',y='FP',title='Under Bonferroni Correction') +
opts(axis.line = theme_segment(colour = "black"),
panel.grid.major = theme_blank(),
panel.grid.minor = theme_blank(),
panel.border = theme_blank(),
panel.background = theme_blank()) + ylim(0.03,0.06)
如果我按组替换形状:
用颜色替换形状/组时:
ggplot(data.and.factors.prov,aes(x=Design.Complexity,y=FP,colour=factor(All.interactions))) +
stat_summary(fun.data=mean_cl_normal,position=position_dodge(width=0.5)) +
geom_blank() +
geom_smooth(method='lm',se=F,formula=y~x,colour='black') +
scale_shape_manual(values=c(17,3,16,6,15,4),
name='Interactions',
labels=c('No interactions','All possible interactions','Randomly picked interactions\nand direct effects')) +
labs(x='Design.complexity',y='FP',title='Under Bonferroni Correction') +
opts(axis.line = theme_segment(colour = "black"),
panel.grid.major = theme_blank(),
panel.grid.minor = theme_blank(),
panel.border = theme_blank(),
panel.background = theme_blank()) + ylim(0.03,0.06)
同时使用颜色和组时
为什么我使用形状时得到3个回归,而使用颜色时只得到1个回归?
使用颜色时如何获得3个彩色回归,使用形状时如何仅获得1个回归?只需删除geom_smooth()中的Color='black',它将自动提供3个回归
如果你想有3个黑色回归,你可以在aes()中使用group=factor(All.interactions)和color=factor(All.interactions),在geom_smooth()中使用color='black'我猜,这是因为在使用
shape
时对组
美学进行了隐式调用,而在使用color
时没有隐式调用。。。你可以通过在你的color
版本中添加group=…
来验证。但我在我的帖子中添加了一些图表,这些图表可能会证实或否定你的假设!我还添加了精度,我希望我的回归能够根据它们所模拟的点进行着色。我大体上同意Justin的评论,但我无法(也不愿意)进一步提供帮助,因为你的代码不可复制。我会支持Joran,请让你的问题可复制。。。但是如果你想让你的回归图上色,不要把color='black'
传递到geom\u smooth
…你可以自己写一个答案并接受它。那是允许的!