We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
geom_label
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
geom_label does not work as expected with a stat of "summary".
Instead, you have to use after_stat, which seems inconsistent with the grammar in how the x and y aesthetics are treated where you don't do this.
after_stat
Could geom_label with a stat of "summary" work with label aesthetic variable?
library(tidyverse) library(tidyplots) #doesn't spendings |> ggplot(aes(y = category, x = amount, label = amount)) + geom_bar(stat = "summary", fun = \(x) sum(x)) + geom_label(stat = "summary", fun = \(x) sum(x)) #> Warning: Removed 5 rows containing missing values or values outside the scale range #> (`geom_label()`).
#works spendings |> ggplot(aes(y = category, x = amount, label = after_stat(x))) + geom_bar(stat = "summary", fun = \(x) sum(x)) + geom_label(stat = "summary", fun = \(x) sum(x))
Created on 2025-05-21 with reprex v2.1.1
The text was updated successfully, but these errors were encountered:
Hi David, thanks for raising the issue!
seems inconsistent with the grammar
Can you elaborate a little bit on how this is inconsistent?
Generally, we avoid specific interactions between stats and geoms. Especially with stats that are as generic as the summary stat.
Sorry, something went wrong.
Actually rereading the help for stat_summary, and this makes sense - as it doesn't operate on aesthetics other than x or y.
"stat_summary() operates on unique x or y;"
Whoops, I should read the help first!!
No branches or pull requests
geom_label
does not work as expected with a stat of "summary".Instead, you have to use
after_stat
, which seems inconsistent with the grammar in how the x and y aesthetics are treated where you don't do this.Could
geom_label
with a stat of "summary" work with label aesthetic variable?Created on 2025-05-21 with reprex v2.1.1
The text was updated successfully, but these errors were encountered: