Skip to content

ggguides 1.1.8

Choose a tag to compare

@gcol33 gcol33 released this 23 Apr 18:52
· 23 commits to main since this release

Bug Fixes

  • legend_left(), legend_right(), legend_top(), and legend_bottom() were writing to legend.justification, the generic fallback element. In ggplot2 >= 3.5.0 each side has its own element — legend.justification.left, legend.justification.right, legend.justification.top, legend.justification.bottom — and the generic fallback is silently coerced per axis. legend_left() in particular was sending "left" to a vertical rail, which ggplot2 coerced to 0 (bottom), so the legend was actually pinned to the bottom of the left edge when users expected it centered. The four side functions now write to the side-specific element and default to "center", which is what the documentation has always described. (reported by Youtao)

New Features

  • legend_left(), legend_right(), legend_top(), and legend_bottom() gain a justification argument. It slides the legend along its rail: "top"/"center"/"bottom" (or a number in [0, 1]) for left/right, "left"/"center"/"right" for top/bottom. This is the side-legend counterpart to legend_inside(justification = ...). For per-guide control when several legends sit on different sides, keep using legend_style(by = ..., justification = ...).

Documentation

  • ?legend_left (and the three siblings) now explain the "rail" semantics and note the naming asymmetry with legend_inside(): on a side, the justification keyword refers to where the legend sits along the panel edge; inside, it refers to which corner of the legend anchors to the (x, y) position.