[問題] 如何在SCATTER PLOT MATRIX中加入BOX PLOT?

看板Statistics作者 (神人毀天滅地)時間17年前 (2009/02/26 17:28), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
如題所述,用的軟體是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
文章代碼(AID): #19fc2zmg (Statistics)