[英]Editing a correlogram
I'm trying to create a correlogram using corrgram package 我正在尝试使用corrgram包创建相关图
library(corrgram)
data("iris")
col.corrgram <- function(ncol) {
colorRampPalette(
c("darkgoldenrod4","burlywood1","darkkhaki","darkgreen")
)(ncol)
}
corrgram(
iris,
order = TRUE,
lower.panel = panel.shade,
upper.panel = panel.pts,
col.regions = col.corrgram
)
The names of variables appear in the diagonal panel. 变量名称显示在对角线面板中。 I need the names on the left and bottom of the correlogram and to create a histogram of each variable in the diagonal panel. 我需要在相关图的左侧和底部分别命名,并在对角线面板中为每个变量创建一个直方图。
Any ideas? 有任何想法吗? Thanks 谢谢
# From 'pairs' help page for plotting histogram
panel.hist <- function(x, ...)
{
usr <- par("usr"); on.exit(par(usr))
par(usr = c(usr[1:2], 0, 1.5) )
h <- hist(x, plot = FALSE)
breaks <- h$breaks; nB <- length(breaks)
y <- h$counts; y <- y/max(y)
rect(breaks[-nB], 0, breaks[-1], y, col = "cyan", ...)
}
# Load library
library(corrgram)
# Plot correlogram
tst <- corrgram(mtcars,
order=TRUE,
diag.panel = panel.hist,
upper.panel = panel.pts,
lower.panel = panel.shade,
text.panel = NULL,
outer.labels = list(bottom = list(labels = colnames(mtcars)),
left = list(labels = colnames(mtcars))))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.