Printing a single row from a ggpairs plot

ggally, ggplot2, r

Solution

Based on tonytonov's answer, I explored the `ggpairs` output and found some attributes that you can modify to get the desired result:

gplot <- GGally::ggpairs(data)
gplot$nrow <- 1
gplot$yAxisLabels <- a$yAxisLabels[1]
print(gplot)

That should render only the first row of plots. I don't think there is an easy way to get a single row that's not the first one, since `$nrow` acts like an upper limit, but simply reordering your columns should do the trick.

Problem

I wanted to make a ggpairs plot of the mtcars data set, but I only care about the relationship between mpg and all the other variables, not between all of the variables and all of the variables. I changed some of the columns to factors ``` mtcars$cyl = as.factor(mtcars$cyl) mtcars$vs = as.factor(mtcars$vs) mtcars$am = as.factor(mtcars$am) mtcars$gear = as.factor(mtcars$gear) mtcars$carb = as.factor(mtcars$carb) ``` and rand the plot ``` ggpairs(mtcars, colour = "am", columns = c(1,2,8:11)) ``` Is there any way I can show just the first row of the plot?

Original source

Related problems