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

Add feature to give legend items row/column locations to appear. #6026

Open
Maschette opened this issue Aug 4, 2024 · 4 comments
Open

Add feature to give legend items row/column locations to appear. #6026

Maschette opened this issue Aug 4, 2024 · 4 comments

Comments

@Maschette
Copy link
Contributor

In situations when we are plotting factors with (in this case points) different types of categories, we would like to be able to have more control on how things appear in the legend. Whilst you can give ggplot the number of rows and columns to use for the legend you cannot (as far as I can find) give it the row/column locations of the factors which would allow you to have empty spaces in the legend like this:

image

I tried to look at the legend source code to suggest a potential implementation but could not work out exactly where the rows and columns are implemented.

@teunbrand
Copy link
Collaborator

I like this idea, but maybe this is a better fit for a guide extension rather than built into guide_legend().
Out of curiosity, how would you expect to feed the group structure to the legend?

@Maschette
Copy link
Contributor Author

I had been thinking about this, my first thought is similar to the named vector option used for values in scale_*_manual() or potentially a list. My guess is that it would eventually need to fit into the params list either as an addition or replacement of the key option and then worked into/ an alternative to the arrange_layout function. https://github.com/tidyverse/ggplot2/blob/7fb4c382f9ea332844d469663a8047355a88dd7a/R/guide-legend.R#L474C3-L474C18

@teunbrand
Copy link
Collaborator

I've been experimenting with a similar thing if you're interested. I don't know if I'm going to move that function around though, so it may not be very stable.

@smouksassi
Copy link

I was thinking more like a patchwork of individual legend key grobs ? and where user can have complete control of the layout ?

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

No branches or pull requests

3 participants