且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

图中的R ggplot2图例

更新时间:2023-11-26 12:21:40

plot1 <- ggplot(data=df, aes(x=xval, y=yval, group=cond, colour=cond) ) +
         geom_smooth(aes(ymin = yval-se, ymax = yval+se,
                     linetype=cond, colour=cond, fill=cond), stat="identity",
                     size=1.1) +
         scale_colour_hue(l=25) +
         ylim(-0.1,1.3) + scale_linetype_manual(values = c('a' = 1,'b' = 2))

plot1 + facet_grid(~ zval, scales="free_y") + 
theme(strip.text.x = element_blank(),
      strip.background = element_rect(colour="white", fill="white"),
      legend.position=c(.9,.75)
      )

调整legend.position值以适合您的喜好.

Tweak the legend.position values to suit your preference.