我有这个代码:
ggplot() +
stat_smooth(data=fd.area.dfa.quant,aes(x=area,y=q50),alpha=0.6,colour="Red")+
stat_smooth(data=fd.area.dfb.quant,aes(x=area,y=q50),alpha=0.6,colour="Green")+
stat_smooth(data=fd.area.cfa.quant,aes(x=area,y=q50),alpha=0.6,colour="Purple")+
stat_smooth(data=fd.area.csb.quant,aes(x=area,y=q50),alpha=0.6,colour="Blue")+
stat_smooth(data=fd.area.bsk.quant,aes(x=area,y=q50),alpha=0.6,colour="Orange")+
scale_x_log10("xlab",expand = c(0, 0),labels=comma)+
scale_y_log10("ylab", expand = c(0, 0.05),labels=comma)+
theme(aspect.ratio=1)+
ggtitle("title")+
ggsave("save2.png")
Run Code Online (Sandbox Code Playgroud)
这就是数字
我想要
PS所有线都有各种尺寸,因此我避免融化.
我该怎么做?
由于你没有共享任何样本数据来使你的代码成为一个简单,可重复的例子,我将使用我自己的代码,你可以调整它
d1<-data.frame(x=1:10, y=cumsum(runif(10)))
d2<-data.frame(x=1:10, y=cumsum(runif(10)))
ggplot() +
stat_smooth(data=d1,aes(x,y,colour="mya"),alpha=0.6)+
stat_smooth(data=d2,aes(x,y,colour="myb"),alpha=0.6)+
scale_color_manual(name="Line",values=c(mya="red",myb="green"))
Run Code Online (Sandbox Code Playgroud)
为了使其工作,我们在aes()调用中设置颜色并为其指定唯一(非颜色)名称.然后,我们手动添加色标并为我们设置的每个aes颜色值定义颜色值.这将正确地为这些值创建图例.
