The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
ggguides simplifies common legend operations in ggplot2. Instead of memorizing theme element names and their nested structure, you can use intuitive one-liner functions to position, style, and manage legends.
Key features:
Position legends with legend_left(),
legend_right(), legend_top(),
legend_bottom(), legend_inside()
Style legends with legend_style() for fonts,
backgrounds, and borders
Wrap legend entries with legend_wrap() for
multi-column layouts
Collect legends from patchwork compositions with
collect_legends()
Or the development version from GitHub:
Let’s create a simple plot to demonstrate the legend helpers:
p <- ggplot(mtcars, aes(mpg, wt, color = factor(cyl))) +
geom_point(size = 3) +
labs(color = "Cylinders")
pPosition the legend on any side with a single function call:
Place the legend inside the plot area using coordinates or shortcuts:
Use legend_style() to customize the legend
appearance:
p + legend_style(
size = 12,
title_size = 14,
title_face = "bold",
background = "#FFF3E0",
background_color = "#FF9800"
)For legends with many entries, use legend_wrap() to
create multi-column layouts:
ggguides functions compose naturally with the +
operator:
ggplot(mpg, aes(displ, hwy, color = class)) +
geom_point() +
legend_left() +
legend_style(size = 12, title_face = "bold", background = "#FFF3E0")ggplot(mpg, aes(displ, hwy, color = class)) +
geom_point() +
legend_wrap(ncol = 2) +
legend_bottom()See the Legend Positioning article for detailed position control
See the Styling & Customization article for advanced styling options
See the Patchwork Integration article for multi-panel workflows
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.