-
Notifications
You must be signed in to change notification settings - Fork 2k
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 expression labels in guide_coloursteps()
and guide_bins()
#6007
base: main
Are you sure you want to change the base?
Conversation
R/guide-colorsteps.R
Outdated
if (is.expression(labels)) { | ||
labels <- as.list(labels) | ||
} |
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.
Wondering if it wouldn't be better if this was the responsibility of Scale$get_labels()
.
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.
yeah... Do we have this call in other places so that moving it to Scale$get_labels()
will allow us to remove some code elsewhere?
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.
In some places for sure. The issue is that, at the moment, it is a balanced trade-off. We have 3 guides where this guard is used, but we also have 3 Scale$get_labels()
methods that might generate expressions.
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.
I think that it logically belongs in get_labels()
as it ensures the output of that function is usable. It shouldn't be the responsibility of the caller to further process the return value to make it work
This PR aims to fix #6005.
Briefly, internally we dance around
<expression>
labels by casting them to lists of expressions when storing them in<data.frame>
s and later unpacking such lists to expressions when handing them off to {grid}. I forgot to do this forguide_coloursteps()
andguide_bins()
, which have very custom code for getting the keys from the scale. This PR rectifies that.Reprex from the issue:
Created on 2024-07-18 with reprex v2.1.1