R ggplot2 legend inside the figure

前端 未结 1 521
你的背包
你的背包 2021-01-31 15:54

So, I have the following data.frame, and I want to generate two plots in one graph for yval vs. xval, for each zval and type tp. The lef

> df
    xval                 


        
相关标签:
1条回答
  • 2021-01-31 16:10
    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)
          )
    

    Tweak the legend.position values to suit your preference.

    0 讨论(0)
提交回复
热议问题