I am trying to use another color palette for the scatter plots from ggpairs
from the GGally
library in R. See similar question here.
library(ggplot2)
library(GGally)
Works
ggplot(iris, aes(x=Sepal.Width, colour=Species)) + stat_ecdf() + scale_color_brewer(palette="Spectral")
Also works
ggplot <- function(...) ggplot2::ggplot(...) + scale_color_brewer(palette="Spectral")
ggplot(iris, aes(x=Sepal.Width, colour=Species)) + stat_ecdf()
Does not work
ggplot <- function(...) ggplot2::ggplot(...) + scale_color_brewer(palette="Spectral")
ggpairs(iris,
columns=, c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"),
colour='Species',
lower=list(continuous='points'),
axisLabels='none',
upper=list(continuous='blank')
)
but adding
putPlot(p, ggplot(iris, aes(x=Sepal.Length, colour=Species)) + stat_ecdf(), 1,1)
adds a plot in the right colors.
Workaround
I can change the plots afterwards with getPlot, but that's not pretty..
subplot <- getPlot(a, 2, 1) # retrieve the top left chart
subplotNew <- subplot + scale_color_brewer(palette="Spectral")
a <- putPlot(a, subplotNew, 2, 1)
How can I change the color scheme for the scatter plots in ggpairs? More specifically, I'd like to manually define the colors like so
scale_colour_manual(values=c("#FF0000","#000000", "#0000FF","#00FF00"))
Thanks!
ggpairs
plot in an object, saygg
and modifygg$plots
– Stéphane Laurent