Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Compatability with ggplot2 3.6.0 #166
base: main
Are you sure you want to change the base?
Compatability with ggplot2 3.6.0 #166
Changes from 2 commits
d0519a0
5e30828
ef4b3d5
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
The expected label is derived from the global mapping of the plot, while ggplot2 now prioritises layers for default mappings (so the path geoms is the one to provide x/y).
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.
No problem, in this case the code is better updated to return
+ ggplot2::labs(x = "Re(1/root)", y = "Im(1/root)")
.Am I correct in understanding that
ggplot(aes(x = mpg, y = hp))
will now return default axis labels ofx = "x"
andy = "y"
rather thanx = "mpg"
andy = "hp"
? Sincegeom_*()
in this case is inheriting from the default ggplotaes()
, it feels like a regression that the path geom wouldn't produce the same x/y 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.
It will be mpg/hp in that case. Essentially it goes over the layers one-by-one and picks up the labels, so the order in which aesthetics are evaluated matters. It ignores the global aesthetics because they only matter when they are inherited by a layer. The relevant issue is tidyverse/ggplot2#5894 if you want to read more.
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.
Thanks for the reference! I'm not against the change, and I think the relevant issue is well motivated.
It seems there could be an issue with using
annotate()
and the new automatic layer-based labels (or I misunderstand their intended interaction -- I haven't read the relevant issue closely yet).Here's an adapted version of
gg_arma()
that removes the model and the package NSE handling junk. The defaultaes(x = Re(1/root), y = Im(1/root), colour = UnitCircle)
results in labelslabs(x = "x", y = "y", colour = "UnitCircle")
for these layers:Removing
annotate()
produces the expected labelslabs(x = "Re(1/root)", y = "Im(1/root)", colour = "UnitCircle")
.Full (not so minimal) MRE (
{reprex}
isn't working for me at the moment, so apologies for the botched output):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.
Looking into
annotate()
a bit more, since it is essentially setting up ageom_path()
I can understand why it is producingx/y
labels. However the resulting labels were a bit surprising to me before I looked into the code sinceannotate()
doesn't have a traditional data+mapping syntax like other layer functions. It is probably difficult to implement, but perhapsannotate()
layers should be ignored for layer-based labels.Perhaps it is best if I just add the desired labels into the plot explicitly.
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 like the suggestion and I've added it to tidyverse/ggplot2#6290