Skip to content
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 problems during ribbon data sort #3235

Merged
merged 2 commits into from Apr 30, 2019

Conversation

thomasp85
Copy link
Member

reverse dependency check picked up an issue with the new sorting of geom_ribbon() in setup_data(). When ymin is set outside aes() it would fail as it wouldn't have access to the variable at setup time. This PR mitigates that.

@thomasp85 thomasp85 added this to the ggplot2 3.2.0 milestone Apr 11, 2019
@clauswilke
Copy link
Member

I vaguely recall that sometimes there are cases where a variable doesn't make it into data but is available in params. This has caused me to write code such as this: https://github.com/clauswilke/ggridges/blob/bb2b9b4c6b1d304fad5da33492b7377c96388f5e/R/geoms.R#L126-L140

Is this applicable here?

@thomasp85
Copy link
Member Author

it seems to be dealing with the same problem... For this specific instance I can't see how/why one would provide both a constant ymin and ymax to geom_ribbon() so either should be available during setup_data()... andI think it is fair to error out if non are an aesthetic...

But if you feel strongly about it I'll adopt your approach

@clauswilke
Copy link
Member

I don't have a strong opinion of how it should be coded. However, I think there are 4 distinct cases that should work, and you can verify whether they all do:

  1. Geom used directly (via geom_ribbon()), ymin/ymax is provided inside of aes().
  2. Geom used directly (via geom_ribbon()), ymin/ymax is provided outside of aes().
  3. Geom used via the geom argument of a stat, ymin/ymax is provided inside of aes().
  4. Geom used via the geom argument of a stat, ymin/ymax is provided outside of aes().

The error message implies that ymin/ymax cannot be used outside of aes() ("must be given as an aesthetic"), and I found that concerning.

@thomasp85
Copy link
Member Author

The error says either so at least one of them must be given in aes(). This is a fair requirement IMO because the existence of one of them defines the horizontal span of the geom... If both were given outside aes() the ribbon would have no width.

Copy link
Member

@clauswilke clauswilke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could consider adding a period at the end of the error message. Otherwise LGTM.

R/geom-ribbon.r Outdated Show resolved Hide resolved
@lock
Copy link

lock bot commented Oct 27, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Oct 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants