R语言base graphics: high level绘图函数
本文是R Graphics的笔记。R语言base graphics绘制图形的方式:首先使用high level绘图函数参数产生一个新的图形,然后使用low level绘图函数添加点、线、文字等其他图形元素。High level绘图函数有:
单变量high level绘图函数
Function | Data | Description |
---|
plot() | Numeric | Scatterplot |
plot() | Factor | Barplot |
plot() | 1-D table | Barplot |
barplot() | Numeric (bar heights) | Barplot |
pie() | Numeric | Pie chart |
dotchart() | Numeric | Dotplot |
boxplot() | Numeric | Boxplot |
hist() | Numeric | Histogram |
stripchart() | Numeric 1-D | scatterplot |
stem() | Numeric | Stem-and-leaf plot |
两个变量high level绘图函数
Function | Data | Description |
---|
plot() | Numeric, numeric | Scatterplot |
plot() | Numeric, factor | Stripcharts |
plot() | Factor, numeric | Boxplots |
plot() | Factor, factor | Spineplot |
plot() | 2-D table | Mosaic plot |
| | |
sunflowerplot() | Numeric, numeric | Sunower scatterplot |
smoothScatter() | Numeric, numeric | Smooth scatterplot |
| | |
boxplot() | List of numeric | Boxplots |
barplot() | Matrix | Stacked/side-by-side barplot |
dotchart() | Matrix | Dotplot |
| | |
stripchart() | List of numeric | Stripcharts |
spineplot() | Numeric, factor | Spinogram |
cdplot() | Numeric, factor | Conditional density plot |
| | |
fourfoldplot() | 2x2 table | Fourfold display |
assocplot() | 2-D table | Association plot |
mosaicplot() | 2-D table | Mosaic plot |
多变量high level绘图函数
Function | Data | Description |
---|
plot( )` | Data frame | Scatterplot matrix |
pairs() | Matrix | Scatterplot matrix |
matplot() | Matrix | Scatterplot |
stars() | Matrix | Star plots |
| | |
image() | Numeric,numeric,numeric | Image plot |
contour() | Numeric,numeric,numeric | Contour plot |
filled.contour() | Numeric,numeric,numeric | Filled contour |
persp() | Numeric,numeric,numeric | 3-D surface |
symbols() | Numeric,numeric,numeric | Symbol scatterplot |
| | |
coplot() | Formula | Conditioning plot |
| | |
mosaicplot() | N-D table | Mosaic plot |
特定图形绘图函数 Specialized plots
plot()
是泛函数,根据传入的对象选择对应的plot函数。qqplot()
和qqnorm()
curve()
函数
plot(function(x) {sin(x)/x},
from=-10*pi, to=10*pi,
xlab="", ylab="", n=500)
# 等价于
curve(sin(x)/x, -10*pi, 10*pi)
- 特定package中的plot的函数,专业领域的绘图