Repository navigation
Make geom_col() ignore data$width - #3194
yutannihilation wants to merge 2 commits into
Conversation
clauswilke
left a comment
There was a problem hiding this comment.
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.
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.
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 intervalsCreated 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 ignorewidthmapping, butgeom_col()does not. Here's my thinking:widthcannot be an aesthetic.widths per bar viadata, not a single value viaparam.data$widthshould 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 asStatIdentitybut I think
geom_col()should ignorewidthfor 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)