如何将轴标签添加到ggcorrplot?我有一张问卷调查中两次不同尝试之间的相关性图。X轴表示第一次尝试,Y轴表示第二次尝试。我想标记这些轴,以表明这就是这里所表示的。
我的代码如下所示:
corrQData <- round(cor(Attempt1, Attempt2), digits = 1)
ggcorrplot(corrQData,
outline.color = "white",
ggtheme = theme_bw(),
colors = c("#F8696B", "#FFEB84", "#63BE7B"),
legend.title = "Correlation",
lab = TRUE,
lab_size = 3,
tl.cex = 8,
tl.srt = 0,
title = "Correlation Between Questionnaire Attempts") +
theme(plot.title = element_text(hjust = 0.5, size=10), legend.title = element_text(size = 10))我的图看起来像这样:

我尝试将+ scale_x_discreet(name = "Attempt 1")添加到我的ggcorrplot代码的末尾,但它没有任何作用。
发布于 2019-08-31 20:49:34
您必须覆盖ggcorrplot的默认行为,即不显示轴标签。通过使用ggplot2::labs() (scale_x_discrete(name = ...)也适用)添加标签并更改绘图主题即可实现此目的
library(ggcorrplot)
corrdata <- round(cor(mtcars), 1)
ggcorrplot(corrdata) +
ggplot2::labs(x = 'X label', y = 'Y label') +
ggplot2::theme(
axis.title.x = element_text(angle = 0, color = 'grey20'),
axis.title.y = element_text(angle = 90, color = 'grey20')
)https://stackoverflow.com/questions/57736945
复制相似问题