-
Notifications
You must be signed in to change notification settings - Fork 2.1k
direction
argument to scale_fill_fermenter
does not behave as documented
#4444
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
Comments
the default is direction = - 1 then when you have direction = 1 it is reversed but then if you have anything other than - 1 you get the same results (scales::brewer_pal only tests for direction = -1) set.seed(2349)
library(ggplot2)
library(patchwork)
# Generate some data to plot
n = 100
tb = data.frame(x = runif(n), y = runif(n))
(ggplot(tb, aes(x = x, y = y, fill = y - x)) +
scale_fill_fermenter(palette = 'PuOr', direction = -1) +
geom_point(pch = 21, color = 'white')+
ggtitle("direction = -1")) +
(ggplot(tb, aes(x = x, y = y, fill = y - x)) +
scale_fill_fermenter(palette = 'PuOr', direction = 1) +
geom_point(pch = 21, color = 'white')+
ggtitle("direction = 1"))+
(ggplot(tb, aes(x = x, y = y, fill = y - x)) +
scale_fill_fermenter(palette = 'PuOr', direction = "blah") +
geom_point(pch = 21, color = 'white')+
ggtitle("direction = blah")) #scales::brewer_pal only tests for direction = -1 Created on 2021-04-23 by the reprex package (v2.0.0) |
Ah I didn't realize the default direction switches from brewer to distiller/fermenter! This clears up my confusion and solves my problem, so I'm closing the issue — thank you! |
Capturing in documentation that scale_*_distiller has a non-intuitive default direction = -1, and that to reverse, user needs to specify direction = 1 Source: tidyverse#1439 tidyverse#4444
…_distiller's non-intuitive "direction" (#5381) * Update scale-brewer.R Capturing in documentation that scale_*_distiller has a non-intuitive default direction = -1, and that to reverse, user needs to specify direction = 1 Source: #1439 #4444 * Move comment from Details to Note * Document --------- Co-authored-by: yutannihilation <yutannihilation@users.noreply.github.com>
Thank you for maintaining ggplot! I'm really enjoying using it in slides and Rmarkdown files as part of my reporting workflow.
I've been using the ColorBrewer palettes, and recently noticed that I'm not able to reverse their directions as expected. For example, the
scale_fill_fermenter()
function with aPuOr
palette places purple on the low end and orange on the high end. I expected that settingdirection = -1
argument would reverse the direction of the palette.Instead,
scale_fill_fermenter()
behaves identically fordirection = 1
anddirection = -1
. I can get my desired behavior by settingdirection = "horizontal"
, but this isn't in the docs.I did a quick search for this behavior in open issues, but the closest thing I could find (#4364) seemed different, so I'm opening the issue. It's not breaking my workflow, but I thought updating the docs or function might save others some time. If the fix is something a new contributor could tackle, I'm happy to give it a shot with a nudge in the right direction!
I've noticed this behavior in ggplot2 version 3.3.3, running in R version 4.0.2., and have a quick trio of examples below.
Created on 2021-04-23 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: