Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change correlation text size in ggpairs()

Tags:

r

ggplot2

I'm using ggpairs() in the GGally package. The pairs plot is of four continuous variables, and I gave another column, a factor with 2 levels, to a colour argument which worked very nicely, both coloring the points as I expected and (bonus!) in the upper-diagonal part of the plot reporting the correlations by that factor level. My only problem is that the text reporting the correlations is too small.

Can I increase the size of the text reporting correlations in a ggpairs() plot?

I tried giving a cex argument, it seems to have no effect. I'm already using size for yet another variable; it doesn't affect the text.

For a specific example:

require(GGally)
mtcars$cyl <- as.factor(mtcars$cyl)
ggpairs(mtcars, columns = c(1, 5), colour = "cyl")
like image 821
Gregor Thomas Avatar asked Dec 22 '11 05:12

Gregor Thomas


2 Answers

For anyone finding their way to this thread in 2017 and beyond, this has changed slightly.

See schloerke's answer here: https://github.com/ggobi/ggally/issues/31

ie. to change the font size used in the correlations, use the upper parameter to the ggpairs function like so:

ggpairs(mtcars, columns = c(1, 5), colour = "cyl",
    upper = list(continuous = wrap("cor", size = 9)))
like image 159
falconaerie Avatar answered Sep 23 '22 07:09

falconaerie


You can also specify the correlation text size in the params. For your example, you could specify a correlation font size of 12 as follows:

require(GGally)
mtcars$cyl <- as.factor(mtcars$cyl)
ggpairs(mtcars, columns = c(1, 5), colour = "cyl", params=list(corSize=12))
like image 29
ordinator Avatar answered Sep 21 '22 07:09

ordinator