-
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
Fix color/fill defaults and behavior #91
Changes from all commits
6c97cbc
0e6f17d
3470a77
490a5b1
ad4dbc4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,15 +14,16 @@ | |
#' specifies the height of the silhouettes in the units of the y axis. The | ||
#' aspect ratio of the silhouettes will always be maintained. | ||
#' | ||
#' The `color` (default: "black"), `fill` (default: NA), 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 the outline and fill color will be | ||
#' the same. If "original" is specified for the `color` aesthetic, the | ||
#' original color of the silhouette outline will be used (usually the same as | ||
#' "transparent"). If "original" is specified for the `fill` aesthetic, the | ||
#' original color of the silhouette body will be used (usually the same as | ||
#' "black"). | ||
#' The `color` (default: NA), `fill` (default: "black"), and `alpha` ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure this is working as expected, e.g.
|
||
#' 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, I am not sure this is behaving as expected:
|
||
#' color (for backwards compatibility). If "original" is specified for the | ||
#' `color` aesthetic, the original color of the silhouette outline will be | ||
#' used (usually the same as "transparent"). If "original" is specified for | ||
#' the `fill` aesthetic, the original color of the silhouette body will be | ||
#' used (usually the same as "black"). To remove the fill or outline, you can | ||
#' set `fill` or `color` to "transparent", respectively. | ||
#' | ||
#' The `horizontal` and `vertical` aesthetics can be used to flip the | ||
#' silhouettes. The `angle` aesthetic can be used to rotate the silhouettes. | ||
|
@@ -74,16 +75,16 @@ | |
#' name = c("Felis silvestris catus", "Odobenus rosmarus")) | ||
#' ggplot(df) + | ||
#' geom_phylopic(aes(x = x, y = y, name = name), | ||
#' color = "purple", size = 10) + | ||
#' fill = "purple", size = 10) + | ||
#' facet_wrap(~name) + | ||
#' coord_cartesian(xlim = c(1,6), ylim = c(5, 30)) | ||
#' } | ||
geom_phylopic <- function(mapping = NULL, data = NULL, | ||
stat = "identity", position = "identity", | ||
..., | ||
na.rm = FALSE, | ||
show.legend = FALSE, | ||
inherit.aes = TRUE, | ||
remove_background = TRUE, | ||
verbose = FALSE, | ||
filter = NULL) { | ||
|
@@ -118,13 +119,12 @@ | |
|
||
#' @importFrom ggplot2 ggproto ggproto_parent Geom aes remove_missing | ||
#' @importFrom grid gTree gList nullGrob | ||
GeomPhylopic <- ggproto("GeomPhylopic", Geom, | ||
Check warning on line 122 in R/geom_phylopic.R GitHub Actions / lint
|
||
required_aes = c("x", "y"), | ||
non_missing_aes = c("size", "alpha", "color", | ||
non_missing_aes = c("size", "alpha", "color", "fill", | ||
"horizontal", "vertical", "angle"), | ||
optional_aes = c("img", "name", "uuid"), # one and only one of these | ||
default_aes = aes(size = 6, alpha = 1, | ||
color = "black", fill = NA, | ||
default_aes = aes(size = 6, alpha = 1, color = NA, fill = "black", | ||
horizontal = FALSE, vertical = FALSE, angle = 0), | ||
extra_params = c("na.rm", "remove_background", "verbose", "filter"), | ||
setup_data = function(data, params) { | ||
|
@@ -212,10 +212,11 @@ | |
data <- ggproto_parent(Geom, self)$use_defaults(data, params, modifiers) | ||
if (col_fill[1] && !col_fill[2]) { | ||
data$fill <- data$colour | ||
data$colour <- NA | ||
} | ||
data | ||
}, | ||
draw_panel = function(self, data, panel_params, coord, na.rm = FALSE, | ||
remove_background = TRUE, filter = NULL) { | ||
phylopic_env$remove_background <- remove_background | ||
# reset the legend key index (since the panel is plotted after the legend) | ||
|
@@ -377,7 +378,7 @@ | |
#' @importFrom grImport2 pictureGrob | ||
#' @importFrom grid rasterGrob gList gTree nullGrob | ||
#' @importFrom methods slotNames | ||
phylopicGrob <- function(img, x, y, height, color, fill, alpha, | ||
Check warning on line 381 in R/geom_phylopic.R GitHub Actions / lint
|
||
horizontal, vertical, angle, | ||
remove_background) { | ||
# modified from add_phylopic for now | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 doesn't seem to be consistent with
add_phylopic_base
?