How to move or position a legend in ggplot2

前端 未结 4 586
野性不改
野性不改 2020-12-03 00:17

I\'m trying to create a ggplot2 plot with the legend beneath the plot.

The ggplot2 book says on p 112 \"The position and justification of legends are controlled by t

4条回答
  •  误落风尘
    2020-12-03 01:03

    Just a few updates to these answers while I'm here. As Hadley mentioned, you can move a legend to the bottom with theme(legend.position = "bottom")

    Or manually move with it theme(legend.position = c(.2,.85))

    If you want the legend to be horizontal, use theme(legend.position = c(.2,.85), legend.direction = "horizontal")

提交回复
热议问题