1. 程式人生 > >R:ggplot2(7),第4章 用圖形構建影象(3)

R:ggplot2(7),第4章 用圖形構建影象(3)

《ggplot2:資料分析與圖形藝術》

第4章 用圖形構建影象

4.6 幾何物件

幾何圖形物件,簡稱為geom,它執行著圖層的實際渲染,控制著生成的影象型別。表4.2列出了ggplot2裡面所有可用的幾何物件。

  • 4.2 ggplot2中的幾何物件
名稱 描述
abline 線,由斜率和截距決定
area 面積圖(area plot)
bar 條形圖,以x軸為底的矩形
bin2d 2維熱圖
blank 空白,什麼也不畫
boxplot 箱線圖
contour 等高線圖
crossbar 帶有水平中心線的盒子圖
density 光滑密度曲線圖
density2d 二維密度等高線圖
dotplot “點直方圖”,用點來表示觀測值的個數
errorbar 誤差棒
errorbarh 水平的誤差棒
freqploy 頻率多邊形圖
hex 用六邊形表示的2維熱圖
histogram 直方圖
hline 水平線
jitter 給點新增擾動,減輕圖形重疊問題
line 按照x座標點大小順序依次連線各個觀測值
linerange 一條代表一個區間的豎直線
map 基準地圖裡的多邊形
path 按資料的原始順序連線各個觀測值
point 點,用來繪製散點圖
pointrange 用一條中間帶點的豎直線代表一個區間
ploygon 多邊形,相當於一個有填充的路徑
quantile 新增分位數迴歸線
raster 高效的矩形瓦片圖
rect 2維的矩形圖
ribbon 色帶圖,連線的x值所對應的y的範圍
rug 邊際地毯圖
segment 新增線段或箭頭
smooth 新增光滑的條件均值線
step 以階梯形式連線各個觀測值
text 文字註釋
tile 瓦片圖
violin 小提琴圖
vline 豎直線

每個幾何物件都有一組它能識別的圖形屬性和一組繪圖所需的值。例如,一個點含有顏色、大小和形狀等圖形屬性,以及x和y位置座標。一個條形含有高度、條寬、邊界顏色和填充顏色等圖形屬性值。表4.3列出了所有幾何物件的圖形屬性值。

  • 表4.3預設的統計變換和圖形屬性。黑體圖形屬性是必須宣告的引數。
名稱 預設的統計變換 圖形屬性
abline abline colour, linetype, size
area identity colour, fill, linetype, size, x, y
bar bin colour, fill, linetype, size, weight, x
bin2d bin2d colour, fill, linetype, size, weight, xmax, xmin, ymax, ymin
blank identity
boxplot boxplot colour, fill, lower, middle, size, upper, weight, x, ymax, ymin
contour contour colour, linetype, size, weight, x, y
crossbar identity colour, fill, linetype, size, x, y, ymax, ymin
density density colour, fill, linetype, size, weight, x, y
density2d density2d colour, linetype, size, weight, x, y
dotplot dotplot colour, fill, x, y
errorbar identity colour, linetype, size, width, x, ymax, ymin
errorbarh identity colour, linetype, size, width, y, ymax, ymin
freqploy bin colour, linetype, size
hex binhex colour, fill, size, x, y
histogram bin colour, fill, linetype, size, weight, x
hline hline colour, linetype, size
jitter identity colour, fill, shape, size, x, y
line identity colour, linetype, size, x, y
linerange identity colour, linetype, size, x, ymax, ymin
map identity colour, fill, linetype, size, x, y, map_id
path identity colour, linetype, size, x, y
point identity colour, fill, shape, size, x, y
pointrange identity colour, fill, linetype, shape, size, x, y, ymax, ymin
polygon identity colour, fill, linetype, size, x, y
quantile quantile colour, linetype, size, weight, x, y
raster identity colour, fill, linetype, size, x, y
rect identity colour, fill, linetype, size, xmax, xmin, ymax, ymin
ribbon identity colour, fill, linetype, size, x, ymax, ymin
rug identity colour, linetype, size
segment identity colour, linetype, size, x, xend, y, yend
smooth smooth alpha, colour, fill, linetype, size, weight, x, y
step identity colour, linetype, size, x, y
text identity angle, colour, hjust, label, size, vjust, x, y
tile identity colour, fill, linetype, size, x, y
violin ydensity weight, colour, fill, size, linetype, x, y
vline vline colour, linetype, size