Intro Ggplot2-2
Intro Ggplot2-2
I N T R O D U C T I O N T O D ATA V I S U A L I Z AT I O N W I T H G G P L O T 2
Rick Scave a
Founder, Scave a Academy
48 geometries
geom_*
abline contour dotplot ji er pointrange ribbon spoke
area count errorbar label polygon rug step
bar crossbar errorbarh line qq segment text
bin2d curve freqpoly linerange qq_line sf tile
blank density hex map quantile sf_label violin
boxplot density2d histogram path raster sf_text vline
col density_2d hline point rect smooth
iris %>%
group_by(Species) %>%
summarise_all(mean) -> iris.summary
# A tibble: 3 x 5
Species Sepal.Length Sepal.Width Petal.Length Petal.Width
<fct> <dbl> <dbl> <dbl> <dbl>
1 setosa 5.01 3.43 1.46 0.246
2 versicolor 5.94 2.77 4.26 1.33
3 virginica 6.59 2.97 5.55 2.03
Note: Avoid plo ing only the mean without a measure of spread, e.g. the standard
deviation.
Rick Scave a
Founder, Scave a Academy
Common plot types
Plot type Possible Geoms
Sca er plots points, ji er, abline, smooth, count
Bar plots histogram, bar, col, errorbar
Line plots line, path
[1] 0.08
Rick Scave a
Founder, Scave a Academy
Bar Plots, with a categorical X-axis
Use geom_bar() or geom_col()
Two types
Absolute counts
Distributions
Two types
Absolute counts
Distributions
Rick Scave a
Founder, Scave a Academy
Common plot types
Plot type Possible Geoms
Sca er plots points, ji er, abline, smooth, count
Bar plots histogram, bar, col, errorbar
Line plots line, path