Skip to content

Ignoring unknown aesthetics "width" for geom_col() #2473

Closed

Description

@Ryo-N7

Similar to issue #2066 , I still am getting unexpected warning messages when width aesthetic clearly specified.

library(ggplot2)
library(dplyr)

## Inputs ----
Low_Level <- -0.848744744010952

df <- data_frame(IndicatorName = c("Ind 04", "Ind 05", "Ind 07", "Ind 11", "Ind 17", "Ind 18"),
                 Perc = c(21.4285714, 100, 95.2380952, 0.4260676, 20, 50),
                 PercWeek = c(21.4285714, 100, 85.7142857, 0.1936671, 20, 50),
                 PercYear = c(21.42857, 61.7284, 95.2381, 19.36671, 20, 50),
                 BehindBy = c(-8.487337, 0, 0, -8.487337, -8.487337, 0))

## Plot ----
ggplot(df, aes(x = IndicatorName)) + 
  geom_col(aes(y = PercWeek, width = 0.5), alpha = 0.6) +
  geom_col(aes(y = PercYear, width = 0.75), alpha = 0.3) +
  geom_col(aes(y = Perc, width = 0.15, fill = BehindBy), color = "black") + 
  scale_fill_gradient("", limits = c(Low_Level, 0), low = "red", high = "green", 
                      guide = FALSE) +
  coord_flip()
#> Warning: Ignoring unknown aesthetics: width

#> Warning: Ignoring unknown aesthetics: width

#> Warning: Ignoring unknown aesthetics: width

Created on 2018-03-06 by the reprex package (v0.2.0).

Activity

  1. batpigandme commented on Mar 5, 2018

    @batpigandme
    Member

    Hi @Ryo-N7,

    Thanks for including a reprex— would you mind paring this down to make it more minimal? The reprex do's and dont's is a helpful guide for this. Basically, you want to remove any extraneous aesthetics and simplify the code as much as possible so that it's easy for maintainers to skim and see the problematic pieces.

    Thanks

  2. added
    reprex
    on Mar 5, 2018
  3. Ryo-N7 commented on Mar 5, 2018

    @Ryo-N7
    ContributorAuthor

    Hi @batpigandme,

    yes, sorry i reprex'd this straight out of my working script.

    updated to something more minimal, is this okay?

  4. batpigandme commented on Mar 5, 2018

    @batpigandme
    Member

    Much better, thanks!

  5. removed
    reprex
    on Mar 5, 2018
  6. karawoo commented on Mar 5, 2018

    @karawoo
    Member

    Since you're not mapping width to a variable it doesn't belong within aes(). I'd do this instead:

    ggplot(df, aes(x = IndicatorName)) + 
      geom_col(aes(y = PercWeek), width = 0.5, alpha = 0.6) +
      geom_col(aes(y = PercYear), width = 0.75, alpha = 0.3) +
      geom_col(aes(y = Perc, fill = BehindBy), width = 0.15, color = "black") + 
      scale_fill_gradient("", limits = c(Low_Level, 0), low = "red", high = "green", 
                          guide = FALSE) +
      coord_flip()
  7. Ryo-N7 commented on Mar 6, 2018

    @Ryo-N7
    ContributorAuthor

    @karawoo oh you're completely right! i thought that old error from #2066 was happening again but it was my fault instead. thanks!

  8. lock commented on Sep 2, 2018

    @lock

    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/

  9. locked and limited conversation to collaborators on Sep 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions