0

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

dww
  • 30,425
  • 5
  • 68
  • 111
max
  • 4,141
  • 5
  • 26
  • 55
  • This question covers how to set alpha in GGally, but not the broader question of the best way to deal with overplotting – divibisan Aug 03 '21 at 15:28
  • 1
    not sure whether to vote to close this as a duplicate *"I've tried setting the alpha value...*" or needs more focus "*Is there a good way to address the overplotting*". – dww Aug 03 '21 at 15:32

1 Answers1

1

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

Martin C. Arnold
  • 9,483
  • 1
  • 14
  • 22
  • Thanks! Also good to note that the same code can be used to set `alpha` instead of `size`. I had success using both. – max Aug 03 '21 at 15:39