Rstudio用corrplot画相关图,手动添加底部标签后显示不全,怎么解决?
library(corrplot)
sim_matrix <- read.csv("similarity_matrix.csv", row.names=1)

# 替换 NA 值为 0
sim_matrix[is.na(sim_matrix)] <- 0
# 设置布局,确保有足够的空间显示标签
par(mar = c(12, 5, 5, 0) ) # 调整图形边距
corrplot(sim_matrix, type = 'lower',
order = 'hclust', tl.col = 'blue',
cl.ratio = 0.2, tl.srt = 45, col = COL2('PuOr', 10),
cl.pos = 'r', tl.pos ='n', is.corr = FALSE, col.lim = c(0, 1))
# 手动添加标签
par(xpd = TRUE)
# 使用text添加底部标签
text(x = seq(1, 19), y = rep(1, 19), labels = colnames(sim_matrix), srt = 45, adj = 1, cex = 0.8)
text(x = rep(0, 19), y = seq(1, 19), labels = rownames(sim_matrix), adj = 1, cex = 0.8)
