Search code examples
rr-corrplot

R Corrplot: italicize Y-axis labels


I have a problem that would be extremely easy to solve in ggplot, but can´t figure out how to make it work in corrplot. How to make y-axis labels in italics??

library(corrplot)
M <- cor(mtcars)
corrplot(M, method="circle") 

Solution

  • If you use font = 3 it will italicize all the axes. If you only want the Y axis, a workaround is:

    par(mar = c(4, 6, 4, 4))
    temp <- corrplot(M, method = "circle", font = 3, tl.pos='n',
                     mar = c(0, 0, 4, 0))
    mtext(unique(temp$corrPos$yName), 
          at = unique(temp$corrPos$y), side = 2, las = 1,
          font = 3)
    mtext(unique(temp$corrPos$xName), 
          at = unique(temp$corrPos$x), las = 2)
    
    

    Output: enter image description here

    Though may need some tweaking of the margins on your end to line things up.