我试图在我的ggplot中移动图例,但guides
和legend.position
等常规命令无效。
这是我的代码:
sum_CH$`Biogeographic Regions`<-factor(sum_CH$`Biogeographic Regions`, levels=c("Jura", "Midland", "North", "East", "South", "West","Swiss"), #changing legend order
labels=c("1", "2", "3", "4",
"5", "6", "7")) #changing legend names
require(ggplot2)
p2<-ggplot(data=sum_CH, aes(x=sum_CH$Day, y=sum_CH$value, group=`Biogeographic Regions`))+geom_line(aes(linetype=`Biogeographic Regions`, color=`Biogeographic Regions`), size=1.1)+
xlab("")+
ylab(expression(atop(paste("%"))))+
ggtitle(expression(atop(paste("XXXX"), paste("XX"))))+
scale_x_discrete(sum_CH$Month, breaks=c(15, 45, 75, 105, 135, 165, 195, 225, 255, 285, 315, 345), labels=month.abb)+ #adding months to x axis
scale_color_manual(values = c("#FFCCCC", "#8ACC66", "#C7EEFC", "#00A9E6", "#BED2FF", "#0070FF", "Black"))+ #changing line color
scale_linetype_manual(values = c (1,1,1,1,1,1,4))+ #changing line type
geom_vline(xintercept=c(150,270), colour="grey", linetype="longdash")+
theme_bw()+
theme(axis.title.y=element_text(size=rel(1)))+
theme(axis.title.x=element_text(size=rel(1)))+
theme(axis.text.x = element_text(size=11, color="black"))+
theme(axis.text.y = element_text(size=13,color="black"))+
theme_classic()+
theme(axis.title.x=element_blank())