Position legend in first plot of facet

让人想犯罪 __ 提交于 2019-11-30 04:24:49
Richie Cotton

Assuming your plot is saved as p

p + opts(
  legend.position = c(0.9, 0.6), # c(0,0) bottom left, c(1,1) top-right.
  legend.background = theme_rect(fill = "white", colour = NA)
)

If you want the legend background partially transparent, change the fill to, e.g., "#ffffffaa".

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))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!