Skip to content
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

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

Closed
Ryo-N7 opened this issue Mar 5, 2018 · 6 comments
Closed

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

Ryo-N7 opened this issue Mar 5, 2018 · 6 comments

Comments

@Ryo-N7
Copy link
Contributor

Ryo-N7 commented Mar 5, 2018

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).

@batpigandme
Copy link
Contributor

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

@batpigandme batpigandme added the reprex needs a minimal reproducible example label Mar 5, 2018
@Ryo-N7
Copy link
Contributor Author

Ryo-N7 commented Mar 5, 2018

Hi @batpigandme,

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

updated to something more minimal, is this okay?

@batpigandme
Copy link
Contributor

Much better, thanks!

@batpigandme batpigandme removed the reprex needs a minimal reproducible example label Mar 5, 2018
@karawoo
Copy link
Member

karawoo commented Mar 5, 2018

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()

@Ryo-N7
Copy link
Contributor Author

Ryo-N7 commented Mar 6, 2018

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

@Ryo-N7 Ryo-N7 closed this as completed Mar 6, 2018
@lock
Copy link

lock bot commented Sep 2, 2018

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/

@lock lock bot locked and limited conversation to collaborators Sep 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants