I have a dataset with relatively large column names. When displaying the ggpairs, they fall outside of the limit, and one cannot read the each plot labels. I have tried theme(axis.text = element_text(size=8))
inside the ggpairs()
command, but it doesn't work. Can you please help me with that?
Asked
Active
Viewed 1,916 times
2

SteveMcManaman
- 391
- 1
- 17
2 Answers
2
You should add the theme
and check if you size is high enough like this:
library(GGally)
data(diamonds, package="ggplot2")
diamonds.samp <- diamonds[sample(1:dim(diamonds)[1], 1000), ]
pm <- ggpairs(
diamonds.samp[, 1:5],
mapping = ggplot2::aes(color = cut),
upper = list(continuous = wrap("density", alpha = 0.5), combo = "box_no_facet"),
lower = list(continuous = wrap("points", alpha = 0.3), combo = wrap("dot_no_facet", alpha = 0.4)),
title = "Diamonds"
)
pm
pm + theme(axis.text = element_text(size = 20))
Created on 2022-08-10 by the reprex package (v2.0.1)

Quinten
- 35,235
- 5
- 20
- 53
-
This doesn't change the axis labels, it changes the axis text. I think these labels are from `facet_wrap()`, so it's for that one has to change the font size somehow. – CoderGuy123 Aug 13 '22 at 12:10
2
To change the column and row labels in the grey boxes of facet_wrap() and ggpairs(), you can specify the size of the strip.text as follows:
pm + theme(strip.text.x = element_text(size = 5),
strip.text.y = element_text(size = 5))
Is this what you meant?

Mick
- 81
- 4