stat 209 a taxonomy of graphics
play

STAT 209 A Taxonomy of Graphics September 17, 2019 Colin Reimer - PowerPoint PPT Presentation

Review ggplot2 Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes STAT 209 A Taxonomy of Graphics September 17, 2019 Colin Reimer Dawson 1 / 39 Review ggplot2 Big Picture Types of Graphs ( geom s) Color Schemes


  1. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes STAT 209 A Taxonomy of Graphics September 17, 2019 Colin Reimer Dawson 1 / 39

  2. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Course Business ● RMarkdown or Lab2 issues? ● Note on Quick Reference Sheets ● HW3 2 / 39

  3. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Today ● Plot ( geom ) types ● Color palettes ● ggplot2 themes 3 / 39

  4. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Coming Up ● Thursday: Version Control ( git and GitHub) ● Tuesday: Integrative lab to “reverse engineer” a published visualization ● Next Thursday: Project 1 workshop 4 / 39

  5. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Outline Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes 5 / 39

  6. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Quick Summary: ggplot2 Figure: Slide by Jordan Crouser at Smith College 6 / 39

  7. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Quick Summary: ggplot2 Figure: Slide by Jordan Crouser at Smith College 6 / 39

  8. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Quick Summary: ggplot2 Figure: Slide by Jordan Crouser at Smith College 6 / 39

  9. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Quick Summary: ggplot2 Figure: Slide by Jordan Crouser at Smith College 6 / 39

  10. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Quick Summary: ggplot2 Figure: Slide by Jordan Crouser at Smith College 6 / 39

  11. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Quick Summary: ggplot2 Figure: Slide by Jordan Crouser at Smith College 6 / 39

  12. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Outline Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes 7 / 39

  13. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Common Graph Types ● Bar Graph ● Histogram ● Box Plot ● Scatterplot ● Line Chart ● Map 8 / 39

  14. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Bar Graph ● Allows comparison of a statistic (often just “amount of data”) across categories ● Can use grouping or stacking to bring in a second 9 / 39 categorical variable and depict combinations

  15. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Histogram ● Show count or proportion within bins of a quantitative variable ● Choice of bin width/cutoffs can affect impression 10 / 39 dramatically

  16. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Box Plot ● Alternative to histogram to show distribution of a quantitative variable ● Can group by a categorical variable to compare distributions 11 / 39

  17. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Scatterplot ● Depicts the relationship between two quantitative variables ● Can bring in additional variables using hue, saturation, symbol ● Can show trend line based on a model (e.g., regression) 12 / 39

  18. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Line Chart ● Useful to depict trends in sequential data ● Essentially a scatterplot with dots connected, but this must make sense ● Can depict groups, or overlay multiple variables to see 13 / 39 when variables move together/apart/switch ordering

  19. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Map ● Useful for geographic data (duh) ● A filled map (like this) is called a chloropleth ● May alternatively plot data point in specific locations 14 / 39

  20. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Pitfalls and Distortions of Maps 15 / 39

  21. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Pitfalls and Distortions of Maps 15 / 39

  22. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Pitfalls and Distortions of Maps 15 / 39

  23. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Pitfalls and Distortions of Maps 15 / 39

  24. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Pitfalls and Distortions of Maps 15 / 39

  25. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes My Personal Fave 16 / 39 Figure: http://xkcd.com/1939/

  26. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Outline Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes 17 / 39

  27. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Choose Colors Intentionally ● Color is not just about aesthetic preference! Colors communicate information ● Universal design: Keep in mind not everyone sees color the same way 18 / 39

  28. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Color Coordinate Systems ● RGB (Red/Green/Blue) ● denotes intensity of each primary color in the color ● useful for color generation, not particularly intuitive for color perception ● HSL (Hue/Saturation/Lightness) ● More naturally describe perceptual properties ● Hue: the dominant “color word” in the rainbow ● Saturation: how “pure” vs. “muted” is the color ● Lightness: how much white or black is in the color 19 / 39

  29. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Taxonomy of Color Palettes ● Sequential: Colors fall on an ordered scale ● Single hue: Uses only saturation/lightness to distinguish ● Multi hue: Varies colors on a hue spectrum ● Diverging: Colors move two directions from a neutral point ● Categorical: No sense of a quantitative scale; mapping for categorical variables only 20 / 39

  30. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Sequential Palette: Single Hue ● Maps a numeric variable to the saturation dimension (sometimes combination of saturation and lightness) ● Higher saturation = More of the thing 21 / 39

  31. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Sequential Palette: Multi Hue ● Maps a numeric variable to an arc in HSB color space, varying hue ● Typically, darker = more 22 / 39

  32. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Diverging Palette ● Two sequential (single hue) scales that “meet in the middle” at a neutral (low saturation) color ● Useful for signed quantitative variable with anchor at zero ● Careful to distinguish missing data! 23 / 39

  33. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Categorical Palette ● A set of (roughly) equally spaced points in a circle in HSB space (i.e., only hue varies) ● Colors indicate levels of a categorical variable 24 / 39

  34. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Some convenient built-in options ● RColorBrewer ● by Cynthia Brewer ( http://www.colorbrewer2.org ) ● has sequential, diverging, categorical palettes ● viridis ● Rudis, Ross and Garnier (link to CRAN documentation) ● Based on color schemes in Python’s matplotlib ● Sequential (multi-hue) only 25 / 39

  35. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes ggplot2 default library(tidyverse) rand_data <- data.frame(x = rnorm(10000), y = rnorm(10000)) norm_plot <- ggplot(rand_data, aes(x = x, y = y)) + geom_hex() + coord_fixed() norm_plot 4 2 count 100 0 y 75 50 25 −2 −4 −4 −2 0 2 4 26 / 39 x

  36. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes ColorBrewer Purples palette library(RColorBrewer) norm_plot + scale_fill_distiller(palette = "Purples") 4 2 count 100 0 75 y 50 25 −2 −4 −4 −2 0 2 4 x 27 / 39

  37. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes ColorBrewer YlGn palette library(RColorBrewer) norm_plot + scale_fill_distiller(palette = "YlGn") 4 2 count 100 0 75 y 50 25 −2 −4 −4 −2 0 2 4 x 28 / 39

  38. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes viridis palette library(viridis) norm_plot + scale_fill_viridis() 4 2 count 100 0 75 y 50 25 −2 −4 −4 −2 0 2 4 x 29 / 39

  39. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Universal Design: Color Blindness 30 / 39

  40. Review ‘ggplot2‘ Big Picture Types of Graphs ( geom s) Color Schemes ggplot2 themes Universal Design: Color Blindness 30 / 39

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend