-
Notifications
You must be signed in to change notification settings - Fork 9
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 phylopic_key_glyph #68
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works really well @willgearty. I know it gave you some pain, so great job. A few things we might want to consider:
- Ensure this works with the updated aesthetics for
geom_phylopic
(use of colour and fill) and outline feature. - Can we make this work with the size aesthetic as well?
- Do we want an option for creating legends for
add_phylopic
andadd_phylopic_base
?
Note: I still need to figure out why one of the tests isn't making the correct snapshot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @willgearty, this is working well! Last thing from me is whether we expect color
defined outside of the aesthetics to also work when multiple values are defined? I think we should be encouraging it to be defined in the aesthetics, but just in case, I thought I'd mention it.
library(ggplot2)
df <- data.frame(x = c(2, 4), y = c(10, 20),
name = c("Felis silvestris catus", "Odobenus rosmarus"))
# Works with outline colour
ggplot(df) +
geom_phylopic(aes(x = x, y = y, name = name, fill = name), color = c("blue"),
size = 10,
show.legend = TRUE,
key_glyph = phylopic_key_glyph(name =
c("Felis silvestris catus",
"Odobenus rosmarus"))) +
coord_cartesian(xlim = c(1,6), ylim = c(5, 30))
# Doesn't work with outline colour (defaults to black)
ggplot(df) +
geom_phylopic(aes(x = x, y = y, name = name, fill = name), color = c("blue", "red"),
size = 10,
show.legend = TRUE,
key_glyph = phylopic_key_glyph(name =
c("Felis silvestris catus",
"Odobenus rosmarus"))) +
coord_cartesian(xlim = c(1,6), ylim = c(5, 30))
This is the expected behavior for a ggplot legend (which should only represent the aesthetics). For example: ggplot(df) +
geom_point(aes(x = x, y = y, fill = name), color = c("blue", "red"), size = 10, shape = 21) +
coord_cartesian(xlim = c(1,6), ylim = c(5, 30)) |
OK, your two other requests/comments have been moved to separate issues for future development. I'll merge this once the checks pass! |
This adds a custom key glyph function that can be used with
geom_phylopic
to specify silhouettes for the legend.Resolves #57.