R - change size of axis labels for corrplot R - change size of axis labels for corrplot r r

R - change size of axis labels for corrplot


Update2

Actually a real reproducible example is now, thanks to code and data being provided:

d1 <- read.csv(url("http://misterdavis.org/r_wiki/r_results_1231_2010"))lpp_axis1 <- with(d1, data.frame("Compile Source Code" = Q3A.1,                                 "View Source Code" = Q3A.2,                                 "Change Source Code" = Q3A.3,                                  "Write Documentation" = Q3A.8,                                  "File Bug Reports"= Q3B.3,                                 "Ask Questions" = Q3B.5,                                 "Provide Answers" = Q3B.6,                                 "Overall Participation" = Q3a3bConsolidated))lpp_axis2 <- with(d1, data.frame("Identification" = Q1,                                 "Overall Learning" = Q6Consolidated,                                   "Learning Programming" = Q6.1,                                 "Learning about Computers" = Q6.2,                                  "Learning Teamwork" =  Q6.3))corrplot(cor(lpp_axis1, lpp_axis2), method=c("number"), bg = "grey10",         addgrid.col = "gray50", tl.cex=1,         tl.col = "black",          col = colorRampPalette(c("yellow","green","navyblue"))(100))dev.new()corrplot(cor(lpp_axis1, lpp_axis2), method=c("number"), bg = "grey10",         addgrid.col = "gray50", tl.cex=2,         tl.col = "black",          col = colorRampPalette(c("yellow","green","navyblue"))(100))

The dev.new() allows you to have both on screen at once to compare, without splitting the plotting region into two panels.

The tl.offset seems to cause more problems than it is worth, so I have left it out. I include the two figures below:

With tl.cex = 1

corrplot with tl.cex = 1

With tl.cex = 2

corrplot with tl.cex = 2

As you can see, I can't reproduce the problem you are seeing; tl.cex is only changing the size of the size of the axis labels. Note this is without using tl.offset but the rest of the plotting code is the same as yours.

This is what I get from packageDescription():

R> packageDescription("corrplot")Package: corrplotType: PackageTitle: visualization of a correlation matrixVersion: 0.30Date: 2010-05-30Author: Taiyun WeiSuggests: seriation, cairoDevice, Cairo,Maintainer: Taiyun Wei <weitaiyun@gmail.com>Description: The corrplot package is a graphical display of a        correlation matrix, confidence interval. It also contains some        algorithms to do matrix reordering.License: GPL-2 | GPL-3LazyLoad: yesURL: http://corrplot.r-forge.r-project.orgRepository: CRANRepository/R-Forge/Project: corrplotRepository/R-Forge/Revision: 45Date/Publication: 2010-05-31 07:44:14Packaged: 2010-05-30 20:39:16 UTC; rforgeBuilt: R 2.13.0; ; 2011-04-01 12:33:21 UTC; unix

-- File: /home/gavin/R/libs/corrplot/Meta/package.rds

Compare it with the one on your system and try the example above so we are running exactly the same code for comparison.


Original ExampleHere is a reproducible example:

require(corrplot)data(mtcars)corr <- cor(mtcars)corrplot(corr, method = "number", tl.cex = 2)

Update

Ok, I see the problem now. With tl.offset, you push the labels away from the correlation graphic further out into the margins. This seems either a bug on infelicity in corrplot() as if you don't set tl.offset it scales the correlation graphic to accommodate the labels. The only solution I can see is to not set tl.offset at all, or set it to a smaller value Here is an extreme example:

layout(matrix(1:2, ncol = 2))corrplot(corr, method = "number", tl.cex = 2, tl.offset = 3)corrplot(corr, method = "number", tl.cex = 2)layout(1)

corrplot 4

You can improve things, by altering the relative dimensions of the plot device - if on screen, increase the width or height (or both) of the plot device window until all the labels are visible. If this is another device (pdf() or png() say), then you'll need to alter the dimensions of the device when you create it.


Original Which [The reproducible example] gives:

mtcars correlation plot

You aren't clear what the problem with the x and y axis labels, but corrplot() alters the plot margins to accommodate the labels. You have already stated the relative size of these x and y axis labels by setting argument tl.cex = 2. If you want the labels bigger, increase this value:

corrplot(corr, method = "number", tl.cex = 4)

mtcars correlation plot 2

and if you want smaller labels, set tl.cex to a smaller value:

corrplot(corr, method = "number", tl.cex = 0.8)

mtcars correlation plot 3

Given these are the only x and y labels on the plot, does this help? If not, which labels need altering?


Given the examples you added, you might have to increase the dimensions of the plot and set the outer margins to accommodate the length of your labels.

The current plot dimension can be accessed with par()$pin and the outer margins with par()$omi .

You can change the plot dimension and the outer margins by adapting the following example:

require("corrplot")         ## needs the corrplot package  data(mtcars)    corr <- cor(mtcars)    par(pin=c(7,7))              ##  (width, height) in inches    par(omi=c(0,1,1,0.5))        ## (bottom, left, top, right)  in inches  corrplot(corr, method="number", tl.cex = 2)

enter image description here



You could try changing the point size of text with par. I think the default size is 12.
Adding a line like par( ps=14) before corrplot should make the text larger.