4

I have a matrix of scatterplots and correlations depicted below. I would like to get rid of the x and y axis (0, 5, 10, 15) numbers that are at each position in the diagonal.

I would also like to get rid of the word "Corr:", so that only the correlation value appears.

Appreciate your help!

Code:

ggpairs(log2(cpmRos[1:100,] + 1), axisLabels="internal", params=c(size=1), upper=list(params=list(size=5))) 
+ theme(axis.ticks=element_blank(), 
axis.line=element_blank(), 
axis.text=element_blank(), 
panel.grid.major= element_blank())

enter image description here

Carmen Sandoval
  • 2,266
  • 5
  • 30
  • 46
  • Removing "Corr:" may take a bit of work, see [this answer](http://stackoverflow.com/a/21747853/2461552). There is an example of axis removal on the `ggpairs` help page, using `axisLabels = "none"`. – aosmith Jun 09 '15 at 15:12
  • Thanks! I actually have `axisLabels = 'internal'` so that the sample names willl show on the diagonal. What I can't seem to get rid of are the numbers on the plot axes which have also been transferred to the diagonal. This is my current code: `ggpairs(log2(cpmRos[1:100,] + 1), axisLabels="internal", params=c(size=1), upper=list(params=list(size=5))) + theme(axis.ticks=element_blank(), axis.line=element_blank(), axis.text=element_blank(), panel.grid.major= element_blank())` – Carmen Sandoval Jun 09 '15 at 18:41

1 Answers1

0

You haven't provide any code or data, so here's an example of how to get rid of the axes and axis labels using the built-in mtcars data set:

library(GGally)

ggpairs(mtcars[,1:4]) + 
  theme(axis.line=element_blank(),
        axis.text=element_blank(),
        axis.ticks=element_blank())

I'm not sure if there's an easy way to get rid of the "Corr" text in each facet. It might be hard-coded.

eipi10
  • 91,525
  • 24
  • 209
  • 285
  • Hi, thanks for your help. I tried adding the theme() parameters you suggest, but the axis numbers are still there for each sample. Here is my code: `ggpairs(log2(cpmRos[1:100,] + 1), axisLabels="internal", params=c(size=1), upper=list(params=list(size=5))) + theme(axis.ticks=element_blank(), axis.line=element_blank(), axis.text=element_blank(), panel.grid.major= element_blank())` – Carmen Sandoval Jun 09 '15 at 18:39
  • `axisLabels="internal"` is what causes the axis labels to be drawn on the diagonal. If you don't want any axis labels, remove that parameter setting. Then the theme statements will also remove any labels or axes on the outside edges where they would normally be drawn. – eipi10 Jun 09 '15 at 20:08
  • But I still want the sample names on the diagonal, and that will get rid of it. – Carmen Sandoval Jun 09 '15 at 20:10
  • It looks like `GGally` has a lot of special-purpose code that hard-codes things like that. I don't know of an easy way to get the flexibility you want. Hopefully someone will be able to provide some code that either modifies the appropriate `GGally` function(s) or uses `grid` functions to do the modifications you're looking for. – eipi10 Jun 09 '15 at 20:13