-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add default aesthetic values to geom docs #5461
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
Conversation
I like this! ❤️ |
I also think this is great!
Technically, one can change the defaults with
I'm a fan of the low clutter option. Maybe the line on top should just read
A few other things to consider:
|
how would the user know the "units" of say size:1.5 |
@smoukassi Most of such details are in the exact vignette that the bottom line refers to, so I think the verbosity is good as-is. |
I used @teunbrand's suggestion for the text at the top. Thanks. I agree with @smouksassi, at least in part. Sure, people can look it up the details, but I remember really struggling with this stuff as a beginner. So now the default value shows as both a number and a string. Which ever one is given, it will look up the other. And it should gracefully handle non-typical values that it can't look up. See the new screenshot at the top. |
ifelse(aes == "linetype", get_linetype_name(default_value), | ||
ifelse(aes %in% c("colour", "fill", "border_colour"), | ||
ifelse(is.na(default_value), '\\code{{NA}} (equivalent to \\code{"transparent"})', get_styled_color(default_value)), | ||
ifelse(aes == "alpha" & is.na(default_value), '\\code{NA} (equivalent to \\code{1})', |
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.
Sorry for nitpicking this, but alpha(x, NA)
is not equivalent to alpha(x, 1)
. Using alpha(x, NA)
preserves the alpha channel, whereas alpha(x, 1)
does not.
library(scales)
alpha("#FF000088", NA)
#> [1] "#FF000088"
alpha("#FF000088", 1)
#> [1] "#FF0000FF"
Created on 2023-10-27 with reprex v2.0.2
The spirit of the PR was included as part of #6285, so I'm closing this PR in favour of the other. |
A common problem, especially for beginner users, is that you make a plot using default aesthetic values, but then you want to adjust them by a relative amount. For example, you make a plot with
geom_point()
, but you want the points to be 50% larger. Is the default size 1? 0.01 (proportion of the chart size)? 10 (pixels)? If you don't know the default value, it's tough to know even what order of magnitude to set the new value to.So, this update adds the default value next to each aesthetic listed in the docs.
It'll impact every geom's documentation, so I wanted to discuss it here before pushing all the generated .RD files.
Stylized values
How values are displayed varies by the aesthetic and type:
19
or"circle"
1
or"solid"
~after_stat(x)
Screenshot from RStudio:
