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

custom legend icons for geom_phylopic #57

Closed
willgearty opened this issue Jun 18, 2023 · 6 comments · Fixed by #68
Closed

custom legend icons for geom_phylopic #57

willgearty opened this issue Jun 18, 2023 · 6 comments · Fixed by #68
Assignees
Milestone

Comments

@willgearty
Copy link
Collaborator

@LewisAJones requests that legends related to geom_phylopic should use the silhouettes instead of points

@willgearty willgearty self-assigned this Jun 18, 2023
@willgearty willgearty added this to the 1.2.0 milestone Jun 18, 2023
@willgearty
Copy link
Collaborator Author

I've been bashing my head against a wall trying to get this to work, but I'm not making any progress on this. I was originally trying to treat img as an aesthetic, so the legend could then have different silhouettes in it. However, it appears that that isn't possible with the way ggplot handles the rendering of legends.

However, I think I can make it such that the user can specify a silhouette to be used for the entire legend. This obviously wouldn't be that useful for plots with multiple different silhouettes, but could be very useful and aesthetically pleasing for plots with just a single unique silhouette.

@willgearty
Copy link
Collaborator Author

willgearty commented Jul 14, 2023

It might even be possible that, if only one unique silhouette is used in a plot, we just use that one automatically.

@LewisAJones
Copy link
Collaborator

Hmm... this should be relatively straightforward to implement. Ultimately, what we want to achieve is just changing the glyph in a legend.

I think the best way to do this is implementing a draw_key_phylopic. This tutorial shows an example of doing this with a smiley face. Maybe start there?

@willgearty
Copy link
Collaborator Author

Yes, it's straightforward to have a single custom image, but not straightforward to have the images be based on the images in the plot itself.

@willgearty
Copy link
Collaborator Author

After many attempts to make this automated, I've resorted to implementing a manual method for users to specify the silhouettes in the legend in the legend-keys branch. Have a look when you get a chance @LewisAJones.

@willgearty
Copy link
Collaborator Author

Some more information: the new method uses a package environment to store data between legend key generations. Unfortunately, this doesn't work for transferring information from the geom renderer to the legend renderer because the legend gets rendered first (ugh).

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

Successfully merging a pull request may close this issue.

2 participants