I would like to change the color palette for the GGally
function ggpairs
. When I attempt to add ggplot commands to the ggplot returned using
I feel like the most non-hacky way to change the palette is to modify its own graphing function since they return ggplot2 objects which can be customized freely.
To change the density in the diagonal, just change the corresponding function, ggally_densityDiag
.
modified_density = function(data, mapping, ...) {
ggally_densityDiag(data, mapping, ...) + scale_fill_brewer(type = "qual", palette = "Set2")
}
Then, provide the new function to ggparis
function call, as below,
ggpairs(iris, columns = 1:3, aes(color = Species),
diag = list(continuous = modified_density))
There are upper
and lower
arguments that can be used for other parts of the plot as well.