我在ggplot2中创建了一个图(见下文)。我还没有想出如何将颜色更改为灰度(移植=是或否,颜色应该是黑色和深灰色),在符号周围带有黑色边框。这将包括符号和错误栏,并应适用于图例。R ggplot2如何更改符号颜色?
如何在符号周围添加黑色边框?我试着将pch=21
添加到geomplot
行,但是搞砸了颜色。
下面是阴谋代码:
# create personal theme for ggplot
my_theme<- theme_grey() + theme(legend.key = element_blank(),axis.text=element_text(size=14),axis.text=element_text(size=14),
axis.title=element_text(size=16,face="bold"),legend.text = element_text(size = 14),
legend.title = element_text(size = 16,face="bold"),legend.position="right",panel.grid.major.x = element_blank(),
strip.text = element_text(size = 15),plot.title = element_text(size = 14, face="bold"))
# create plot
ggplot(data=trans_X,aes(x=Location, y=pred,group= Substrate)) +
geom_line(aes(linetype= Substrate,group=Substrate),size=1)+
geom_point(data=trans_X, aes(shape=transferred, group= transferred,fill=transferred,color=transferred),size=6)+
geom_errorbar(data=trans_X, position=position_dodge() ,aes(ymin=pred-2*sd,ymax=pred+2*sd, color=transferred),size=0.51,width=0.1)+
my_theme+
scale_fill_discrete(name="Transplanted")+
scale_color_manual(name="Transplanted", values = c("no" = "gray10","yes" = "gray40"))+
scale_shape_discrete(name="Transplanted")+
scale_linetype_manual(name="Wrackbed substrate",
breaks=c("Steninge","M\366lle","K\344mpinge","K\u00E5seberga"),
values=c(1,5,3,6))+
labs(y="Predicted mean development time",x="Fly origin")
'?scale_color_grey'? – Jaap
是的,我试过,但我得到一个错误告诉我,颜色已经设置。你能给我一个例子修改我的代码吗?谢谢! –
我认为完全跛脚给一个-1没有评论?我正在努力创造一个不错的情节,并看看我的代码! –