Position legend in first plot of facet
问题 I would like to put my plot legend inside the plot, inside the first plot of a facet. Here is some example code: df=data.frame( x=runif(10), y=runif(10), facet=rep(c("a","b"),5), color=rep(c("red","blue"),5)) ggplot(data=df,aes(x=x,y=y,color=color))+ geom_point()+ facet_wrap(~facet,ncol=1) Here is the resulting plot: And here is roughly how I would like it to look: Thanks for any help you can provide! 回答1: Assuming your plot is saved as p p + opts( legend.position = c(0.9, 0.6), # c(0,0)