bxp
位於 graphics
包(package)。 說明
bxp
根據 z
中給定的摘要繪製箱線圖。它通常從 boxplot
內部調用,但也可以直接調用。
用法
bxp(z, notch = FALSE, width = NULL, varwidth = FALSE,
outline = TRUE, notch.frac = 0.5, log = "",
border = par("fg"), pars = NULL, frame.plot = axes,
horizontal = FALSE, ann = TRUE,
add = FALSE, at = NULL, show.names = NULL,
...)
參數
z |
包含用於構建繪圖的數據摘要的列表。這些通常是調用 |
notch |
如果 |
width |
給出構成繪圖的框的相對寬度的向量。 |
varwidth |
如果 |
outline |
如果 |
notch.frac |
(0,1) 中的數字。當 |
border |
字符或數字(向量),框邊框的顏色。可回收用於多個盒子。用作 |
log |
字符,指示是否應以對數刻度繪製任何軸,如 |
frame.plot |
邏輯,指示是否應繪製‘frame’( |
horizontal |
邏輯表明箱線圖是否應該是水平的;默認 |
ann |
一個邏輯值,指示默認注釋(標題以及 x 和 y 軸標簽)是否應出現在繪圖上。 |
add |
邏輯,如果 true 將箱線圖添加到當前繪圖。 |
at |
給出應繪製箱線圖的位置的數值向量,特別是當 |
show.names |
設置為 |
pars,... |
graphical parameters (等)可以作為參數傳遞給此函數,可以作為列表( 現在, 此外,接受 以下參數(或
|
值
一個不可見的向量,實際上與 at
參數相同,具有框中心的坐標(如果水平為 false,則為 "x",否則為 "y"),可用於添加到繪圖中。
注意
當 add = FALSE
時,xlim
現在默認為 xlim =
range(at, *) + c(-0.5, 0.5)
。如果 "x" 軸具有對數刻度或 width
遠不均勻,則通常最好指定 xlim
。
例子
require(stats)
set.seed(753)
(bx.p <- boxplot(split(rt(100, 4), gl(5, 20))))
op <- par(mfrow = c(2, 2))
bxp(bx.p, xaxt = "n")
bxp(bx.p, notch = TRUE, axes = FALSE, pch = 4, boxfill = 1:5)
bxp(bx.p, notch = TRUE, boxfill = "lightblue", frame.plot = FALSE,
outline = FALSE, main = "bxp(*, frame.plot= FALSE, outline= FALSE)")
bxp(bx.p, notch = TRUE, boxfill = "lightblue", border = 2:6,
ylim = c(-4,4), pch = 22, bg = "green", log = "x",
main = "... log = 'x', ylim = *")
par(op)
op <- par(mfrow = c(1, 2))
## single group -- no label
boxplot (weight ~ group, data = PlantGrowth, subset = group == "ctrl")
## with label
bx <- boxplot(weight ~ group, data = PlantGrowth,
subset = group == "ctrl", plot = FALSE)
bxp(bx, show.names=TRUE)
par(op)
## passing gap.axis=* to axis(), PR#18109:
boxplot(matrix(100*rnorm(1e3), 50, 20),
cex.axis = 1.5, gap.axis = -1)# showing *all* labels
z <- split(rnorm(1000), rpois(1000, 2.2))
boxplot(z, whisklty = 3, main = "boxplot(z, whisklty = 3)")
## Colour support similar to plot.default:
op <- par(mfrow = 1:2, bg = "light gray", fg = "midnight blue")
boxplot(z, col.axis = "skyblue3", main = "boxplot(*, col.axis=..,main=..)")
plot(z[[1]], col.axis = "skyblue3", main = "plot(*, col.axis=..,main=..)")
mtext("par(bg=\"light gray\", fg=\"midnight blue\")",
outer = TRUE, line = -1.2)
par(op)
## Mimic S-Plus:
splus <- list(boxwex = 0.4, staplewex = 1, outwex = 1, boxfill = "grey40",
medlwd = 3, medcol = "white", whisklty = 3, outlty = 1, outpch = NA)
boxplot(z, pars = splus)
## Recycled and "sweeping" parameters
op <- par(mfrow = c(1,2))
boxplot(z, border = 1:5, lty = 3, medlty = 1, medlwd = 2.5)
boxplot(z, boxfill = 1:3, pch = 1:5, lwd = 1.5, medcol = "white")
par(op)
## too many possibilities
boxplot(z, boxfill = "light gray", outpch = 21:25, outlty = 2,
bg = "pink", lwd = 2,
medcol = "dark blue", medcex = 2, medpch = 20)
作者
The R Core development team and Arni Magnusson (then at U Washington) who has provided most changes for the box*, med*, whisk*, staple*, and out* arguments.
參考
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
相關用法
- R barplot 條形圖
- R box 在地塊周圍畫一個方框
- R boxplot.matrix 為矩陣的每列(行)繪製箱線圖
- R boxplot 箱線圖
- R legend 將圖例添加到繪圖中
- R plot.histogram 繪製直方圖
- R points 向繪圖添加點
- R stem 莖葉圖
- R mtext 將文本寫入繪圖的邊距
- R arrows 將箭頭添加到繪圖中
- R contour 顯示輪廓
- R pairs 散點圖矩陣
- R stars 星圖(蜘蛛圖/雷達圖)和線段圖
- R coplot 調節圖
- R smoothScatter 具有平滑密度顏色表示的散點圖
- R mosaicplot 馬賽克圖
- R plot.raster 繪製光柵圖像
- R axTicks 計算軸刻度線位置
- R curve 繪製函數圖
- R plot.factor 繪製因子變量
- R sunflowerplot 製作向日葵散點圖
- R plot.table 表對象的繪圖方法
- R units 圖形單位
- R identify 識別散點圖中的點
- R layout 指定複雜的繪圖安排
注:本文由純淨天空篩選整理自R-devel大神的英文原創作品 Draw Box Plots from Summaries。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。