How to move or position a legend in ggplot2

前端 未结 4 579
野性不改
野性不改 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:07

    In versions > 0.9.3 (when opts was deprecated)

    theme(legend.position = "bottom")
    

    Older version:

    Unfortunately it's a bug in ggplot2 which I really really hope to fix this summer.

    Update:

    The bug involving opts(legend.position = "left") has been fixed using the most current version of ggplot2. In addition, version 0.9.0 saw the introduction of guide_legend and guide_colorbar which allow much finer control over the appearance and positioning of items within the legend itself. For instance, the ability specify the number of rows and columns for the legend items.

提交回复
热议问题