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

Unable to use fixed alpha aesthetic when color is mapped to a factor #1932

Closed
logworthy opened this issue Nov 29, 2016 · 2 comments
Closed
Labels
bug an unexpected problem or unintended behavior

Comments

@logworthy
Copy link

I'm trying to use a fixed alpha aesthetic to manually highlight points in a plot. It fails when color is mapped to a factor.

library(ggplot2)
data(mtcars)

# fails (but should work)
ggplot(mtcars, aes(x=disp, y=hp, color=as.factor(cyl)))+geom_point(alpha=seq(0,1,length.out=32))
# Error: Aesthetics must be either length 1 or the same as the data (3): alpha

# fails (and should fail)
ggplot(mtcars, aes(x=disp, y=hp, color=as.factor(cyl)))+geom_point(alpha=seq(0,1,length.out=3))
# Error: Aesthetics must be either length 1 or the same as the data (32): alpha

# succeeds
ggplot(mtcars, aes(x=disp, y=hp, color=cyl))+geom_point(alpha=seq(0,1,length.out=32))

Tested on version 2.2.0

@hadley hadley added the bug an unexpected problem or unintended behavior label Jan 25, 2017
@hadley
Copy link
Member

hadley commented Jan 25, 2017

This was a tricky one - it turns out the problem was with the legend.

@hadley hadley closed this as completed in 0b57d83 Jan 25, 2017
@logworthy
Copy link
Author

Thanks!

pkq added a commit to pkq/ggplot2 that referenced this issue May 15, 2018
Reverse inadvertent deletion of 'not' in 'aesthetics that are not length one'
pkq added a commit to pkq/ggplot2 that referenced this issue May 15, 2018
Reverse inadvertent deletion of 'not' in 'aesthetics that are not length one'
hadley pushed a commit that referenced this issue May 15, 2018
Reverse inadvertent deletion of 'not' in 'aesthetics that are not length one'
@lock lock bot locked as resolved and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants