R ggplot2 legend inside the figure R ggplot2 legend inside the figure r r

R ggplot2 legend inside the figure


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.