0

I have a 1 row 2 column plot which I need to insert into a report. When I insert the plot I notice there's a large white area around both correlation plots. Is there an argument in the corrplot function to reduce this? I've read here about using knitr hook functions to crop pdfs but that a bridge too far for my coding capabilities. I've messed around with the par() arguments such as omi and mai but when I export the image to TIFF I still get a huge white space area.

My code so far looks as follows, please note this is hacked together from various sources and dputs to both correlation matrices can be found here and here:

col <- colorRampPalette(c("#BB4444", "#EE9988", "#FFFFFF", "#77AADD", "#4477AA"))

par(mfrow=c(1,2),omi=c(0,0,0,0),mai=c(0.1,0.1,0.1,0.1))

corrplot(LX0088U21A1_24hrCor, method = "color", col = col(200),
         type = "upper", order = "original", number.cex = 0.85,
         addCoef.col = "black", # Add coefficient of correlation
         tl.col = "black", tl.srt = 90,
         number.digits = 1,
         # Text label color and rotation
         # hide correlation coefficient on the principal diagonal
         diag = FALSE,
         #title = "Intraday Correlation LX0088U21A1",
         mar=c(0,0,1,0))
legend(0.5,5,ncol = 1, cex = 1.5,legend = "(a)", box.lwd = 0, box.col = "white")

corrplot(LX0088U09A3_24hrCor, method = "color", col = col(200),
         type = "upper", order = "original", number.cex = 0.75,
         addCoef.col = "black", # Add coefficient of correlation
         tl.col = "black", tl.srt = 90,
         number.digits = 1,
         # Text label color and rotation
         # hide correlation coefficient on the principal diagonal
         diag = FALSE,
         #title = "Intraday Correlation LX0088U09A3",
         mar=c(0,0,1,0))
legend(0.5,5,ncol = 1, cex = 1.5,legend = "(b)", box.lwd = 0, box.col = "white")

Any help is greatly appreciated.

enter image description here

TheGoat
  • 2,587
  • 3
  • 25
  • 58
  • think this is more to do with the aspect ratio and your device dimensions, eg, put a `box('outer')` around your figure and increase the width of the figure in your knitr script – rawr Mar 13 '18 at 00:32
  • wow the version i have is almost 2 years old, not sure how I managed that as how my computer isnt even that old.. but the version on cran has an argument that allows you to control the aspect ratio in some figures https://github.com/cran/corrplot/blob/master/R/corrplot.R#L198:L199 – rawr Mar 13 '18 at 00:45
  • Try the solution in my question https://stackoverflow.com/a/49118535/786542 – Tung Mar 13 '18 at 05:23

0 Answers0