Position legend in first plot of facet

后端 未结 2 547
野性不改
野性不改 2020-12-25 11:28

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=runi         


        
2条回答
  •  长发绾君心
    2020-12-25 11:37

    Or, building on @Richie Cotton's answer, since opts is deprecated in ggplot2 now (still assuming your plot is defined as p)

    p + theme(legend.position = c(0.9, 0.6)
              ,legend.background = element_rect(fill = "white", colour = NA))
    

提交回复
热议问题