ggforce
ggforce copied to clipboard
Add scale_color_units to allow for units in continous color scales.
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 :)