可以使用low level的图形函数添加点、线、图形、图像和文字。这些添加的元素落在plot region区域,受clip区域的控制。
基本的图像函数有:
Function | Description |
---|---|
points() | Draw data symbols at locations (x, y) |
lines() | Draw lines between locations (x, y) |
segments() | Draw line segments between (x0, y0) and (x1, y1) |
arrows() | Draw line segments with arrowheads at the end(s) |
xspline() | Draw a smooth curve relative to control points (x, y) |
rect() | Draw rectangles with bottom-left corner at (xl, yb) and top-right corner at (xr, yt) |
polygon() | Draw one or more polygons with vertices (x, y) |
polypath() | Draw a single polygon made up of one or more paths with vertices (x, y) |
rasterImage() | Draw a bitmap image |
text() | Draw text at locations (x, y) |
此外:
Function | Description |
---|---|
mtext() | 在margin区域输出文字。 title() 函数是特殊的mtext函数。 |
box() | 绘制plot region的边框 |
legend() | 绘制legend。 需要显式指定。 ggplot2可以自动生成legend |
axis() | 绘制自定义的坐标轴 |
坐标系说明
Name | Description |
---|---|
“user” | The scales on the plot axes |
“inches” | Inches, with (0, 0) at bottom-left |
“device” | Pixels for screen or bitmap output, otherwise 1=72in. |
“ndc” | Normalized coordinates, with (0, 0) at bottom-left and (1, 1) at top-right, within the entire device |
“nic” | Normalized coordinates within the inner region |
“nfc” | Normalized coordinates within the gure region |
“npc” | Normalized coordinates within the plot region |