Fundamentals & Workflows
09:00-10:30
View slides in full screen | Run the code yourself
Outline
Recap
- a basic ggplot is build by specifying three components:
data
,aes
thetics and alayer
(usually ageom_*
orstat_*
) - aesthetic mappings define how variables map to visual properties
- the default appearance of all other components can be modified via
scale_*
,coord_*
,facet_*
andtheme_*
/theme
- use the devices cairo (pdf) and agg (png, jpg, tiff) when saving plots
- find a suitable plot size by setting figure chunk options in qmd/rmd files or with the help of the
{camcorder}
package - define conditional components, custom layers and functions to generate plots more efficiently and to iterate over multiple inputs
- combine multiple plot outputs with
{patchwork}
Exercises
Exercise 1
- Discuss / investigate with your neighbor:
- What are the differences between
geom_line()
andgeom_path()
? - Why can you use
geom_smooth()
andstat_smooth()
interchangeably? - What are the three ways to remove a legend from a ggplot?
- Which is your favorite theme?
- What is your favorite ggplot2 extension package?
- What are the differences between
Exercise 2
- Explore the TfL bike share data visually:
- Create a time series of counts per day and night.
- Draw box and whisker plots of average temperatures per month.
- Visualize bike counts per weather type and period as bar chart.
- Combine the three plots with {patchwork}.
- Export the final graphic in a format of your choice.