R语言base graphics绘图设置
R语言base graphics绘图系统全局保存了一组参数,控制绘图的区域、颜色、线性、坐标等等
绘图区域(plotting regions)
inner region = figure region (inner region相对于outer region)
data symbols and lines -> plot region
axes and labels -> figure margins or outer margins
The size and location of the different regions: par()
Coordinate systems
user coordinates: x,y的坐标轴(axes)的标尺(scales)直观易于理解。
normalized coordinate systems:x和y的范围规范到[0,1], 坐标l是图形位置的相对比例。
Base graphics state
High Level Settingpar() plot() ... | Description |
---|---|
adj | Justication of text |
ann | Draw plot labels and titles? |
bg | Background color |
bty | Type of box drawn by box() |
cex (cex.axis, cex.lab, cex.main, cex.sub) | Size of text (multiplier) |
col (col.axis, col.lab, c、ol.main, col.sub) | Color of lines and data symbols |
family | Font family for text |
fg | Foreground color |
font ( font.axis, font.lab, font.main, font.sub) | Font face (bold, italic) for text |
lab | Number of ticks on axes |
las | Rotation of text in margins |
lend, ljoin, lmitre | Line end/join style |
lty | Line type (solid, dashed) |
lwd | Line width |
mgp | Placement of axis ticks and tick labels |
pch | Data symbol type |
srt | Rotation of text in plot region |
tck | Length of axis ticks (relative to plot size) |
tcl | Length of axis ticks (relative to text size) |
xaxp | Number of ticks on x-axis |
xaxs | Calculation of scale range on x-axis |
xaxt | X-axis style (standard, none) |
xpd | Clipping region |
yaxp | Number of ticks on y-axis |
yaxs | Calculation of scale range on y-axis |
yaxt | Y-axis style (standard, none) |
Low Level Settingpar() | Description |
---|---|
fig | Location of figure region (normalized) |
fin | Size of figure region (inches) |
lheight | Line spacing (multiplier) |
mai | Size of figure margins (inches) |
mar | Size of figure margins (lines of text) |
mex | Line spacing in margins |
mfcol | Number of figures on a page |
mfg | Which figure is used next |
mfrow | Number of figures on a page |
new | Has a new plot been started? |
oma | Size of outer margins (lines of text) |
omd | Location of inner region (normalized) |
omi | Size of outer margins |
pin | Size of plot region (inches) |
plt | Location of plot region (normalized) |
ps | Size of text (points) |
pty | Aspect ratio of plot region |
usr | Range of scales on axes |
xlog | Logarithmic scale on x-axis? |
ylog | Logarithmic scale on y-axis? |
Read-only setting
Setting par("xxx") | Description Section |
---|---|
cin | Size of a character (inches) |
cra | Size of a character (\pixels") |
cxy | Size of a character (user coordinates) |
din | Size of graphics device (inches) |
page | Will the next plot start a new page? |
绘图控制项分类
设置项 | 设置变量 |
---|---|
颜色 color | col, fg, bg. (fill pattern: density, angle) |
线 line | lty, lwd ljoin, lend, lmitre |
文本 text | size: ps, cex font: font, family justification: adj(坐标点相对于text区域的位置) rotation: srt axes and title: ann multi-line: lheigh |
数据展现 data symbol | pch (point character), cex, ps, type |
坐标轴 axes | ticks marks: lab, xaxp, yaxp position: mgp length: tck, tck axes style: xaxs, yaxs axes type: xaxt, yaxt (s/n) transformation: xlog, ylog axes border: bty (box type) limits: xlim, ylim |
绘图区 plot region | outer region: oma figure region: fig(l, r, b, t), fin(w, h) figure margin:mar(b, l, t, r), mai (inches), mex (multifier) plot region: plt(l,r, b, t) - ratio. pin(w, h) in inches. occupy type: pty (m|s) |
裁剪 clipping | xpd; clip() |
新起绘图区 new plot | new, devAskNewPage() 提示是否新起一页 |
一页多图 multiple plots | mfrow/mfcol function: layout(), split.screen(), screen(), erase.screen(), close.screen() |