lattice绘图工具
| grid.pars | 網格圖形參數 |
| fontsize | 用于文本和符號兩個組件(每個組件都是數字標量)的列表 |
| clip | 面板和條帶兩個組件的列表(每個組件都有一個字符串,“開”或“關”) |
條件變量
graph_function(formula|v,data=,options)
如果條件變量為連續型,需要轉為離散型
面板函數
分組變量
將不同水平的變量疊加到一起
頁面擺放
借助plot函數的splite和position
lattice包繪圖函數的常用參數
| x | 要繪制的對象 |
| data | x為表達式時,動用一個數據框 |
| allow.multiple | 對于Y1+Y2X/Z,TRUE時重疊繪制Y1X和Y2X,FALSE時繪制Y1+Y2X |
| outer | FALSE繪制疊加,TRUE不在一個面板顯示 |
| box.ratio | 內部矩形長寬比 |
| horizontal | 水平或者垂直 |
| panel | 面板函數 |
| aspect | 不同面板的寬高比 |
| groups | |
| auto.keys | 添加分組變量的圖例符號 |
| prepanel | |
| strip | |
| xlab,ylab | |
| scales | |
| subscripts | |
| subset | |
| xlim,ylim | |
| drop.unused.levels | |
| default.scales | |
| options |
barchart
trellis.par.get("axis.text") trellis.par.set(list(axis.text = list(cex=1))) barchart(Titanic,layout=c(4,1),auto.key=TRUE) barchart(Titanic,layout=c(4,1),auto.key=TRUE,scales = list(x="free")) barchart(Sex~Freq|Class+Age,data = as.data.frame(Titanic),groups=Survived,stack=TRUE,layout=c(8,1),auto.key=TRUE,scales=list(x="free")) barchart(Sex~Freq|Class+Age,data = as.data.frame(Titanic),groups=Survived,stack=TRUE,layout=c(8,1),auto.key=list(title="Survived",columns=2),scales=list(x="free"))
點圖
dotplot(VADeaths,groups = FALSE,layout=c(1,4),aspect=0.5,origin=0,type=c(“p”,“h”))
直方圖
histogram(x,
data,
allow.multiple, outer = TRUE,
auto.key = FALSE,
aspect = “fill”,
panel = lattice.getOption(“panel.histogram”),
prepanel, scales, strip, groups,
xlab, xlim, ylab, ylim,
type = c(“percent”, “count”, “density”),
nint = if (is.factor(x)) nlevels(x)
else round(log2(length(x)) + 1),
endpoints = extend.limits(range(as.numeric(x),
finite = TRUE), prop = 0.04),
breaks,
equal.widths = TRUE,
drop.unused.levels =
lattice.getOption(“drop.unused.levels”),
…,
lattice.options = NULL,
default.scales = list(),
default.prepanel =
lattice.getOption(“prepanel.default.histogram”),
subscripts,
subset)
核密度圖
densityplot(x,
data,
allow.multiple = is.null(groups) || outer,
outer = !is.null(groups),
auto.key = FALSE,
aspect = “fill”,
panel = lattice.getOption(“panel.densityplot”),
prepanel, scales, strip, groups, weights,
xlab, xlim, ylab, ylim,
bw, adjust, kernel, window, width, give.Rkern,
n = 512, from, to, cut, na.rm,
drop.unused.levels =
lattice.getOption(“drop.unused.levels”),
…,
lattice.options = NULL,
default.scales = list(),
default.prepanel =
lattice.getOption(“prepanel.default.densityplot”),
subscripts,
subset)
帶狀圖
panel.stripplot(x, y, jitter.data = FALSE,
factor = 0.5, amount = NULL,
horizontal = TRUE, groups = NULL,
…,
identifier = “stripplot”)
Q-Q圖
根據理論分布繪制樣本的分位數-分位數圖
qqmath(x,
data,
allow.multiple = is.null(groups) || outer,
outer = !is.null(groups),
distribution = qnorm,
f.value = NULL,
auto.key = FALSE,
aspect = “fill”,
panel = lattice.getOption(“panel.qqmath”),
prepanel = NULL,
scales, strip, groups,
xlab, xlim, ylab, ylim,
drop.unused.levels = lattice.getOption(“drop.unused.levels”),
…,
lattice.options = NULL,
default.scales = list(),
default.prepanel = lattice.getOption(“prepanel.default.qqmath”),
subscripts,
subset)
箱型圖
bwplot(x,
data,
allow.multiple = is.null(groups) || outer,
outer = FALSE,
auto.key = FALSE,
aspect = “fill”,
panel = lattice.getOption(“panel.bwplot”),
prepanel = NULL,
scales = list(),
strip = TRUE,
groups = NULL,
xlab,
xlim,
ylab,
ylim,
box.ratio = 1,
horizontal = NULL,
drop.unused.levels = lattice.getOption(“drop.unused.levels”),
…,
lattice.options = NULL,
default.scales,
default.prepanel = lattice.getOption(“prepanel.default.bwplot”),
subscripts = !is.null(groups),
subset = TRUE)
散點圖矩陣
三維水平圖
三維等高線圖
三維散點圖
三維曲面圖
總結
以上是生活随笔為你收集整理的lattice绘图工具的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 怎么用电脑把mp4格式转换成mp3格式
- 下一篇: 机器学习入门实战——决策树算法实战Tit