Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guide custom order #6199

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #6195.

Briefly, it applies the order argument, which is encoded into the names of guides after the merge step.

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2

df <- tibble::tribble(
  ~x, ~y, ~color, ~shape, 
  1, 2, "grey", 1,
  2, 2, "red", 2
) |>
  dplyr::mutate(shape = as.factor(shape))
circle <- grid::circleGrob()
custom <- guide_custom(circle, title = "My circle", order = 1,
                       width = unit(2, "cm"), height = unit(2, "cm"))
color_legend <- guide_legend(order = 3)
shape_legend <- guide_legend(order = 2)

ggplot(df, aes(x, y, color = color, shape = shape)) +
  geom_point() + 
  guides(color = color_legend, 
         shape = shape_legend,
         custom = custom)

Created on 2024-11-25 with reprex v2.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

guide_custom does not adhere to legend order
1 participant