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

Add scale_color_units to allow for units in continous color scales. #236

Closed
ekatko1 opened this issue Mar 23, 2021 · 2 comments
Closed

Add scale_color_units to allow for units in continous color scales. #236

ekatko1 opened this issue Mar 23, 2021 · 2 comments

Comments

@ekatko1
Copy link

ekatko1 commented Mar 23, 2021

It would be great if continuous color scales could also have units.

Example:

library(ggplot2)
library(units)
library(ggforce)

# Plot looks great without units:
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color = Petal.Length)) + 
  geom_point()

# Adding units to the dataset
iris$Sepal.Length =  set_units(iris$Sepal.Length, cm)
iris$Sepal.Width  =  set_units(iris$Sepal.Width,  cm)
iris$Petal.Length =  set_units(iris$Petal.Length, cm)
iris$Petal.Width  =  set_units(iris$Petal.Width,  cm)

ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color = Petal.Length)) + 
  geom_point()

The ggplot with units in the color aesthetic causes the following error:

Error in Ops.units(x, range[1]) : 
  both operands of the expression should be "units" objects

Thanks :)

@ilikegitlab
Copy link

+1 from me. It works for group, but not color or fill.

@thomasp85
Copy link
Owner

Since units support has been moved from ggforce to units itself I'm closing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants