2

I have this code that generates the plot below.

library(ggplot2)
library(GGally)

data(iris)
ggpairs(data = iris[, 1:4], axisLabels = "none", switch = "both")

enter image description here I'd like to do three things with this plot: 1) remove the gridlines in the correlation windows; 2) increase font size of the x-y axes labels; and 3) make these label-backgrounds white (instead of gray). The first question was addressed about 4 years ago here and here, and it seems one would need to either rebuild GGally package, or use a custom code from GitHub. Both options are pretty heavy for a newbie like me, and I am wondering if someone has figured out an easier method by now. I have not found my 2nd and 3rd questions addressed anywhere.

Thanks.

Manojit
  • 611
  • 1
  • 8
  • 18
  • 1
    try the `cor_fun` from https://stackoverflow.com/questions/37889222/change-colors-in-ggpairs-now-that-params-is-deprecated/37890371#37890371 , although there may be easier ways now! – user20650 Jan 04 '18 at 22:27
  • 1
    Make label backgrounds white and increase font size: `+ theme(strip.background = element_rect(fill="white", colour="black"), strip.text = element_text(size=15))`. – eipi10 Jan 04 '18 at 22:41
  • @eipi10 That's cool - thanks! I am also wondering if I over-complicated this by switching facet_labels from top+right to bottom+left (usng`switch = "both")`. Wish there is a simpler way, like turning off facet_labels and turning on axes-labels. – Manojit Jan 04 '18 at 22:48

1 Answers1

3

The first request can be handled by:

+theme(panel.grid.minor = element_blank(), 
        panel.grid.major = element_blank())

The size of the axis labels (which are really in "strips" can be handled with this additional arguemnt to theme:

    ... , strip.text = element_text(size = 5))
IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • 6
    The Society for the Preservation of the English Adverb would like to request that in the future you use "works perfectly". – IRTFM Jan 04 '18 at 22:56
  • Someone commented [here](https://english.stackexchange.com/questions/76214/something-worked-perfectly-vs-something-worked-perfect) that Perfect has been used as adverb since the 15th century :) – Manojit Jan 04 '18 at 23:22
  • 1
    Non-standard is what it was called. Are you claiming that because you are in the hadleyverse that anything non-standard is acceptable? – IRTFM Jan 04 '18 at 23:50