Concepts of the {ggplot2} Package Pt. 2
12:00-12:30
View slides in full screen | Run the code yourself
Outline
- Facet Types
- Wrapped Facets
- Facet Multiple Variables
- Facet Options: Cols + Rows
- Facet Options: Free Scaling
- Facet Options: Switch Labels
 
- Gridded Facets
- Facet Multiple Variables
- Facet Options: Proportional Spacing
 
- Scales
- Continuous vs. Discrete in {ggplot2}
- Aesthetics + Scales
- scale_x|y_continuous
- scale_x|y_date
- scale_x|y_datewith- strftime()
- scale_x|y_discrete
- Discrete or Continuous?
- scale_color|fill_discrete
- Inspect Assigned Colors
- scale_color|fill_manual
- scale_color|fill_carto_d
 
- Coordinate Systems
- Cartesian Coordinate System
- Changing Limits
- Clipping
- Fixed Coordinate System
- Flipped Coordinate System
- Circular Coordinate System
- Transform a Coordinate System
- Spatial Coordinate (Reference) Systems
 
Recap
- facet_*()functions allow to create small multiples
- scale_*()functions translate between aesthetics and properties
- use *_continuous()for numerical data
- … and *_discrete()for categorical data
- use scale_color|fill_*()to customize data-related colors
- coord_*()functions interpret the positional aesthetics, e.g. create polar plots or work with spatial projections
- be careful when adjusting axis limits:
- scale_*_continuous(limits)removes the data outside the range
- coord_*(*lim)keeps the data and zooms into the range
 
Exercises
Exercise 1
- Open the script exercises/03_concepts_pt2_ex1.qmd(or the.rmd).
- Have a look at the visualization in the folder exercises/3-1-astronaut-vizthat shows the cumulative time that cosmo- and astronauts have spent in outer space. The data also contains information on the year of their first and last travel, respectively. 
 - Together with your group, discuss which layers and modifications are needed to create such a chart with {ggplot2}.
- Note down the aesthetics, geometries, and scales used for each element of this graphic.
- What is the coordinate system? Have any adjustments been made?
- Which theme was used and how was it modified?
 
- Together with your group, discuss which layers and modifications are needed to create such a chart with 
→ Solution
Exercise 2
- Open the script exercises/03_concepts_pt2_ex2.qmd(or the.rmd).
- Create a circular lollipop plot of reported bike shares per season.
- The data is not in the right format as there are no totals. How can you solve it?
- Remove all legend elements (with a single line of code).
- How can you add the labels next to the starting point of each lollipop?
- How could you add a baseline?
→ Solution