Reputation: 473
How can I save the ggpairs as the current ggsave does not work?
Script:
library(GGally)
library(ggplot2)
data(diamonds, package="ggplot2")
diamonds.samp <- diamonds[sample(1:dim(diamonds)[1],200),]
pf<-ggpairs( diamonds.samp[,1:3],mapping = ggplot2::aes(color = cut))
ggsave("C:/Users/top/Desktop/ggpairs.jpg", pf, dpi=500)
Upvotes: 2
Views: 2697
Reputation: 25844
If you try to use ggsave
you get an error
ggsave("ggpairs.jpg", pf, dpi=500)
Saving 7 x 7 in image Error in UseMethod("grid.draw") : no applicable method for 'grid.draw' applied to an object of class "c('gg', 'ggmatrix')"
So you can write you own grid.draw
method for the ggpairs
object class
grid.draw.gg <- function(x){
print(x)
}
ggsave("ggpairs.jpg", pf, dpi=500)
Upvotes: 3