Skip to content

geom_bar()/geom_col() erroneously warn that they ignore width aesthetic  #3142

Closed
@richierocks

Description

@richierocks

geom_bar() and geom_col() let you specify a width aesthetic to control the width of the bars.

The behavior is as expected, but it generates an erroneous warning "Warning: Ignoring unknown aesthetics: width".

width isn't listed in the aesthetics section of ?geom_bar, so it appears that this is an unofficial behavior.


library(ggplot2)
suppressPackageStartupMessages(library(dplyr))
mtcars_by_cyl <- mtcars %>% 
  group_by(cyl) %>% 
  summarize(
    mean_wt = mean(wt),
    n = n()
  ) %>% 
  mutate(prop = n / sum(n))

ggplot(mtcars_by_cyl) + 
  geom_col(aes(cyl, mean_wt, width = prop))
#> Warning: Ignoring unknown aesthetics: width

Created on 2019-02-13 by the reprex package (v0.2.0).


Similar closed issues.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions