2.8 Geoms
The geom_point()
geom gives a familiar scatterplot.
Other geoms
include:
geom_smooth()
which fits a smooth line to the data- check
help
to seegeom_smooth
’s arguments likemethod
,se
orspan
.
- check
geom_boxplot()
which generates a box-and-whisker plot- check
help
to seegeom_boxplot
’s arguments likeoutlier
arguments, andcoef
which adjusts the whisker length.
- check
- consider boxplot variants like
geom_jitter
andgeom_violin
geom_histogram
which generates a histogram andgeom_freqpoly
which generates a frequency polygoncheck
help
to seegeom_histogram
’s arguments likeposition
andbinwidth
.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
geom_bar
which generates a bar chartcheck
help
to seegeom_bar
’s arguments likeposition
andwidth
This graph below uses displ
for y
in the aesthetic and uses the stat
of identity
so that it sums the total displacement for each manufacturer.
This plot now shows the total displacement.
## # A tibble: 15 × 2
## manufacturer `sum(displ)`
## <chr> <dbl>
## 1 audi 45.8
## 2 chevrolet 96.2
## 3 dodge 162
## 4 ford 113.
## 5 honda 15.4
## 6 hyundai 34
## 7 jeep 36.6
## 8 land rover 17.2
## 9 lincoln 16.2
## 10 mercury 17.6
## 11 nissan 42.5
## 12 pontiac 19.8
## 13 subaru 34.4
## 14 toyota 100.
## 15 volkswagen 60.9
geom_line
andgeom_path
which generates a line chart or path chart (useful for time series data)- check
help
to seegeom_line
’s arguments likelineend
andarrow
- check
- To investigate these plots further, we can draw them on the same plot.