简体   繁体   English

R Corrplot:斜体 Y 轴标签

[英]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 .我有一个在ggplot中非常容易解决的问题,但无法弄清楚如何让它在corrplot中工作。 How to make y-axis labels in italics??如何用斜体制作y轴标签?

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

If you use font = 3 it will italicize all the axes.如果您使用font = 3 ,它将使所有轴斜体。 If you only want the Y axis, a workaround is:如果您只想要 Y 轴,解决方法是:

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: Output: 在此处输入图像描述

Though may need some tweaking of the margins on your end to line things up.尽管可能需要对您的边距进行一些调整以对齐。

In corrplot , there is a ... argument which allows extra parameters to be passed to the base R text function.corrplot中,有一个...参数,它允许将额外的参数传递给基础 R text function。 Since text has a font parameter, where the value 3 means italics, you can do:由于text有一个font参数,其中值 3 表示斜体,您可以这样做:

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

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM