# Layer :: geom

## 설정 & 매핑

### setting

color=”red”

`mpg %>% ggplot(aes(displ, hwy)) + geom_point(color="blue")`

### mapping

aes(color=class)

 ggplot의 aes mapping이  아래 geom_point Layer에 상속이 됨 geom_point의 aes mapping은 아래 geom_smooth에 상속안됨 ggplot의 aes mapping중 color가 geom_smooth 까지 상속되어, class별 lm smooth 선이 그려짐. ```mpg %>% ggplot(aes(displ, hwy)) + geom_point(aes(color=class)) + geom_smooth(method="lm", se=F)``` ```mpg %>% ggplot(aes(displ, hwy, color=class)) + geom_point() + geom_smooth(method="lm", se=F)```

1.

## geom (기하객체, geometric object)

### geom과 stat의 결합

```d <- ggplot(diamonds, aes(price))
d + stat_bin(geom="bar")

d + stat_bin(geom="area")

d + stat_bin(aes(size=..ndensity..),geom="point")

d + stat_bin(aes(y=1, fill=..density..),geom="tile")```

geom과 stat 객체들은 먼저 소개했던 링크(http://had.co.nz/ggplot2)에 정리돼 있으니 참고 바란다.

 geom_abline       Reference lines: horizontal, vertical, and diagonal geom_area          Ribbons and area plots geom_bar Bars charts geom_bin2d Heatmap of 2d bin counts geom_blank Draw nothing geom_boxplot A box and whiskers plot (in the style of Tukey) geom_col Bars charts geom_contour            2d contours of a 3d surface geom_density2d        Contours of a 2d density estimate geom_density_2d      Contours of a 2d density estimate geom_count Count overlapping points geom_crossbar Vertical intervals: lines, crossbars & errorbars geom_curve Line segments and curves geom_density Smoothed density estimates geom_dotplot Dot plot geom_errorbar Vertical intervals: lines, crossbars & errorbars geom_errorbarh Horizontal error bars geom_freqpoly Histograms and frequency polygons geom_hex Hexagonal heatmap of 2d bin counts geom_histogram Histograms and frequency polygons geom_hline Reference lines: horizontal, vertical, and diagonal geom_jitter Jittered points geom_label Text geom_line Connect observations geom_linerange Vertical intervals: lines, crossbars & errorbars geom_map Polygons from a reference map geom_path Connect observations geom_point Points geom_pointrange Vertical intervals: lines, crossbars & errorbars geom_polygon Polygons geom_qq A quantile-quantile plot geom_quantile Quantile regression geom_raster Rectangles geom_rect Rectangles geom_ribbon Ribbons and area plots geom_rug Rug plots in the margins geom_segment Line segments and curves geom_smooth Smoothed conditional means geom_spoke Line segments parameterised by location, direction and distance geom_step Connect observations geom_text Text geom_tile Rectangles geom_violin Violin plot geom_vline Reference lines: horizontal, vertical, and diagonal

Categories: ggplot2

Blog Owner