Skip to content

geom_label + summary: after_stat but before scale #4235

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

Closed
gregleleu opened this issue Oct 13, 2020 · 3 comments
Closed

geom_label + summary: after_stat but before scale #4235

gregleleu opened this issue Oct 13, 2020 · 3 comments

Comments

@gregleleu
Copy link
Contributor

I'm using stat summary to compute statistics directly in the graph and show a label for it, for example showing the 90% percentile.
The computed value is passed to the label aesthetic using after_stat and that works fine when there are no axis transformations, but with a log10 transformation the label is in the right place but the text is after the transformation and but before the transformation.
From the documentation I would expect after_stat to be before any scale transformation.

Works fine with regular scale:

library(ggplot2)

ggplot(cars) +
  geom_step(aes(x = speed), stat = "ecdf") +
  geom_label(aes(x = speed, y = 0.9, label = after_stat(x)),
             orientation = "y", stat = "summary", fun = quantile, fun.args = list(probs = 0.9))

image

Wrong text with log10 transformation:

library(ggplot2)

ggplot(cars) +
  geom_step(aes(x = speed), stat = "ecdf") +
  geom_label(aes(x = speed, y = 0.9, label = after_stat(x)),
             orientation = "y", stat = "summary", fun = quantile, fun.args = list(probs = 0.9)) + 
  scale_x_log10()

image

@clauswilke
Copy link
Member

Is this the same as #4155?

@gregleleu
Copy link
Contributor Author

Looks like it, yes. I has searched at "label" and "after_stat"; didn't think the issue affected other mappings (it doesn't in my example for some reason)

@clauswilke
Copy link
Member

Ok, I'll close this then in favor of the issue we have already open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants