Reputation:
I am looking for a smooth way to change a ggplot2
output to grey level.
Here an example:
iris <- iris
library(mlr3)
example <- TaskClassif$new(id = "iris", backend = iris, target = "Species")
library(GGally, ggplot2, mlr3viz)
autoplot(example, type = "pairs")
And what I wish to have is a scheme like this:
To be honest, I am unable to solve my "problem" with ggplot2
's cheatsheet. I think I need sth. like + scale_color_grey(start = 0.8, end = 0.2)
or + scale_fill_grey(start = 0.8, end = 0.2)
.
Thanks!
Upvotes: 0
Views: 345
Reputation: 38063
I'm not quite sure where the confusion is coming from, as your intuition seems totally correct to me. When I use the scale_colour_grey()
is does exactly what you would expect and what you describe should be the outcome.
autoplot(example, type = "pairs") +
scale_colour_grey(aesthetics = c("fill", "colour")) + # fill and colour at the same scale
theme_classic() # Eliminite confusing grey background
If you want the species/grey level order reversed, you can set limits in the scale, e.g.:
autoplot(example, type = "pairs") +
scale_colour_grey(aesthetics = c("fill", "colour"),
limits = rev(unique(iris$Species))) +
theme_classic()
Upvotes: 1