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

Fix color/fill defaults and behavior #91

Merged
merged 5 commits into from
Nov 20, 2023
Merged

Fix color/fill defaults and behavior #91

merged 5 commits into from
Nov 20, 2023

Conversation

willgearty
Copy link
Collaborator

@willgearty willgearty commented Nov 16, 2023

This fixes the behavior of the color and fill arguments/aesthetics such that full backwards compatibility is now maintained (no more unnecessary outlines). I've also changed the defaults of these arguments and updated the examples and vignettes to better encourage folks to use fill instead of color moving forward.

TLDR: no more chubby penguins

Fixes #87.

@willgearty willgearty added the bug label Nov 16, 2023
@willgearty willgearty added this to the 1.3.0 milestone Nov 16, 2023
@willgearty willgearty self-assigned this Nov 16, 2023
Copy link
Collaborator

@LewisAJones LewisAJones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @willgearty, thanks for getting this together! I've made a few comments and potentially caught some unexpected behaviour... let me know your thoughts!
L.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this legend have a cat and a walrus?

@@ -171,13 +171,12 @@ The `rotate_phylopic()` function can be used to rotate a silhouette an arbitrary
img_rot <- rotate_phylopic(img = img, angle = 45)
```

Finally, the `recolor_phylopic()` function can be used to modify the color and/or transparency of a silhouette. The vast majority of PhyloPic silhouettes are black and fully opaque by default. However, it may be useful to change this when the you are trying to either match an existing visualization color palette or trying to convey extra information, such as categorical data, through color.
Finally, the `recolor_phylopic()` function can be used to modify the fill color, outline color, and/or transparency of a silhouette. The vast majority of PhyloPic silhouettes are solid black, are fully opaque, and have a transparent outline by default. However, it may be useful to change this when the you are trying to either match an existing visualization color palette or trying to convey extra information, such as categorical data, through color.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Finally, the `recolor_phylopic()` function can be used to modify the fill color, outline color, and/or transparency of a silhouette. The vast majority of PhyloPic silhouettes are solid black, are fully opaque, and have a transparent outline by default. However, it may be useful to change this when the you are trying to either match an existing visualization color palette or trying to convey extra information, such as categorical data, through color.
Finally, the `recolor_phylopic()` function can be used to modify the fill color, outline color, and/or transparency of a silhouette. The vast majority of PhyloPic silhouettes are solid black, are fully opaque, and have a transparent outline by default. However, it may be useful to change this when the you are trying to either match an existing visualization color palette or trying to convey extra information, such as categorical data, through color.

Transparent outline or lack of outline?

#' horizontal = hor, vertical = ver)
#' p + ggtitle("R Cat Herd!!")
add_phylopic <- function(img = NULL, name = NULL, uuid = NULL, filter = NULL,
x, y, ysize = Inf,
alpha = 1, color = "black", fill = NA,
alpha = 1, color = NA, fill = "black",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to be consistent with add_phylopic_base?

#' transparency (outline and fill) of the silhouettes, respectively. If
#' `color` is specified and `fill` is NA the outline and fill color will be
#' the same. If "original" is specified for the `color` aesthetic, the
#' The `color` (default: NA), `fill` (default: "black"), and `alpha` (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this is working as expected, e.g.

library(ggplot2)
df <- data.frame(x = c(2, 4), y = c(10, 20),
                 name = c("Felis silvestris catus", "Odobenus rosmarus"))
ggplot(df) +
  geom_phylopic(aes(x = x, y = y, name = name), color = NA, size = 10) +
  facet_wrap(~name) +
  coord_cartesian(xlim = c(1,6), ylim = c(5, 30))

image

#' The `color` (default: NA), `fill` (default: "black"), and `alpha` (
#' default: 1) aesthetics can be used to change the outline color, fill color,
#' and transparency (outline and fill) of the silhouettes, respectively. If
#' `color` is specified and `fill` is NA `color` will be used as the fill
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I am not sure this is behaving as expected:

library(ggplot2)
df <- data.frame(x = c(2, 4), y = c(10, 20),
                 name = c("Felis silvestris catus", "Odobenus rosmarus"))
ggplot(df) +
  geom_phylopic(aes(x = x, y = y, name = name), fill = NA, color = "blue", size = 10) +
  facet_wrap(~name) +
  coord_cartesian(xlim = c(1,6), ylim = c(5, 30))

image

@LewisAJones LewisAJones self-requested a review November 20, 2023 18:37
Copy link
Collaborator

@LewisAJones LewisAJones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good now, thanks @willgearty!

@willgearty willgearty merged commit e19e0ea into main Nov 20, 2023
10 checks passed
@willgearty willgearty deleted the outline-fix branch November 20, 2023 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Silhouette outlines being added by default
2 participants