-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Make geom_col() ignore data$width #3194
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
Make geom_col() ignore data$width #3194
Conversation
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.
Do you want to mention in the documentation that geom_col()
enforces equal column widths?
# To ensure bar widths are constant within a PANEL, `width` is not allowed | ||
# to be mapped to data. So, even if the `data` already contains `width`, it | ||
# should be ignored except when the width is calculated by Stat. But, as | ||
# geom_col() uses stat_identity() fixedly, this is not the case. |
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.
Just wanted to point out that if somebody writes code such as stat_bin(geom = "col")
they could arrive here with a calculated width
column, but that would probably be considered inappropriate use then. May be worth a mention in the comment, for the future.
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.
Sure.
Yes, I think it's good to have it documented clearly. |
Hmmm, sorry, after thinking about To fix this, I think we need to remove library(ggplot2)
ggplot(diamonds) +
stat_bin(aes(carat, width = stat(count)), geom = "col")
#> Warning: Ignoring unknown aesthetics: width
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`. ggplot(diamonds) +
stat_bin(aes(carat, width = stat(count)), geom = "bar")
#> Warning: Ignoring unknown aesthetics: width
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: position_stack requires non-overlapping x intervals Created on 2019-03-22 by the reprex package (v0.2.1) |
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/ |
Fix #3142
Currently,
geom_bar()
does ignorewidth
mapping, butgeom_col()
does not. Here's my thinking:width
cannot be an aesthetic.width
s per bar viadata
, not a single value viaparam
.data$width
should be used only when it's a calculated value by Stat. But, asgeom_col()
is not the case, it should ignoredata$width
.Note that, this doesn't prevent variable widths when
geom_bar()
uses such Stat asStatIdentity
but I think
geom_col()
should ignorewidth
for consistency at least.Current HEAD
Created on 2019-03-19 by the reprex package (v0.2.1.9000)
This PR
Created on 2019-03-19 by the reprex package (v0.2.1.9000)