Search code examples
rggplot2data-visualizationggally

How to address overplotting in GGally::ggpairs()?


I'm using the ggpairs() function from the GGally package, but I'm having an issue dealing with overplotting.

Is there a good way to address the overplotting? I've tried setting the alpha value but I couldn't find out how to pass it to ggpairs(). I also looked into using geom_hex but again, I couldn't see how to use it with ggpairs().

Here's a simple example:

# Create example data
df <- data.frame(x1=rnorm(1e4),
             x2=rnorm(1e4),
             x3=runif(1e4))

# Pairs plot
GGally::ggpairs(df)

enter image description here


Solution

  • To reduce overplotting of the points you may modify the size aesthetic in point based layers displayed in the lower triangular of the plot matrix:

    GGally::ggpairs(df, lower=list(continuous=GGally::wrap("points", size = .01)))
    

    enter image description here