作者darkwiny (神人毁天灭地)
看板Statistics
标题[问题] 如何在SCATTER PLOT MATRIX中加入BOX PLOT?
时间Thu Feb 26 17:28:28 2009
如题所述,用的软体是R,我有两个自变数的资料
若以指令pairs(),中间会出现两个变数的名称
但如何将其取代成各变数的box plot呢?
R里面有范例是在中间话直条图,不过它是用写程式的方式
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", ...)
}
pairs(USJudgeRatings[1:5], panel=panel.smooth,
cex = 1.5, pch = 24, bg="light blue",
diag.panel=panel.hist, cex.labels = 2, font.labels=2)
大概是这样,然後被我乱改了一下,变成:
panel.plot <- function(x, ...)
{
usr <- par("usr"); on.exit(par(usr))
par(usr = c(usr[1:2], 0, 1.5) )
h <- boxplot(data$X1, data$X2, data$X3)
breaks <- h$breaks; nB <- length(breaks)
y <- h$counts; y <- y/max(y)
rect(breaks[-nB], 0, breaks[-1], y, col="cyan", ...)
}
pairs(data[1:3], panel=panel.smooth,
cex = 1.5, pch = 24, bg="light blue",
diag.panel=panel.plot, cex.labels = 2, font.labels=2)
想当然尔,还是解不出我想要的图,请有在绘图领域的高手指点迷津一下吧!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 122.117.44.100