5.8 Numeric vs. numeric: Scatterplots + smoother

5.8.1 Data & Packages & functions

  • geom_smooth(): Adds smoother
    • geom_smooth(se= FALSE): Display confidence interval around smooth?
  • method = "loess"
    • Default for small n, uses a smooth local regression(as described in?loess)
    • Wiggliness of the line is controlled by the span parameter, which ranges from 0 (exceedingly wiggly) to 1 (not so wiggly)
  • If n > 1000 alternative smoothing algorithm is used (Wickham 2016, 19)

5.8.2 Graph

  • Figure 5.13 and 5.14 provide two examples:
  • Questions:
    • What does the graph show? What are the underlying variables (and data)?
    • How many scales/mappings does it use? Could we reduce them?
    • What do you like, what do you dislike about the figure? What is good, what is bad?
    • What kind of information could we add to the graph (if any)?
    • How would you approach a replication of the graph?
Small multiples of scatterplots

Figure 5.13: Small multiples of scatterplots

Scatterplot with colored subsets

Figure 5.14: Scatterplot with colored subsets


Wickham, Hadley. 2016. Ggplot2: Elegant Graphics for Data Analysis. Springer.