class: center, middle ## Data Visualization <img src="img/DAW.png" width="500px"/> <span style="color: #91204D;"> .large[Kelly McConville| Math 141 | Week 1 | Fall 2020] </span> --- ## Announcements * Lab 01 is due BEFORE your Week 2 lab. + You will practice uploading assignments on Gradescope. + We will come back to this on Monday, once everyone has had their first lab period. --- ## Week 1 Topics * Statistical Thinking * Structure of data * (Lab) Working in RStudio using RMarkdown documents * **Data Viz** --- # Goals for Today * Motivate data visualizations. * Develop the language to talk about the components of a graphic. * Practice deconstructing graphics. * Discuss good graphical practices. --- class: middle, inverse, center # Why construct a graph? Think of an answer and type it into the in-class channel but don't hit send until I say so. --- # Why construct a graph? * To summarize the data. * To look for trends. * To make comparisons and explore relationships. * **To tell a compelling story.** --- # Challenger * On January 27th, 1986, engineers from Morton Thiokol recommended NASA delay launch of space shuttle *Challenger* due to cold weather. * Believed cold weather impacted the o-rings that held the rockets together. * Used 13 charts in their argument. * After a two hour conference call, the engineer's recommendation was overruled due to lack of persuasive evidence and the launch proceeded. * The Challenger exploded 73 seconds into launch. --- # Challenger * Here's one of those charts. <img src="img/table_o_rings.jpg" width="70%" style="display: block; margin: auto;" /> --- # Challenger * Here's another one of those charts. <img src="img/o_ring_rockets.jpg" width="40%" style="display: block; margin: auto;" /> --- # Challenger * The following is a graphic I created from Edward Tufte's data. <img src="wk01_fri_files/figure-html/unnamed-chunk-3-1.png" width="60%" style="display: block; margin: auto;" /> --- # Challenger * This adaptation is a recreation of Edward Tufte's graphic. <img src="wk01_fri_files/figure-html/unnamed-chunk-4-1.png" width="50%" style="display: block; margin: auto;" /> * For more information on this example and other examples, check out [Tufte's book](https://www.edwardtufte.com/tufte/books_visex). --- # Grammar of Graphics * **data**: data frame that contains the raw data + Variables * **geom**: geometric shape that the data are mapped to. + point, line, bar, text, ... * **aesthetic**: visual properties of the **geom** + x position, y position, color, fill, shape * **scale**: controls how data are mapped to the visual values of the aesthetic. + EX: particular colors * **guide**: legend to help user convert visual display back to the data **For today: we won't focus on the names of particular types of graphs (e.g., scatterplot).** --- class: left, middle # Example 1 <img src="img/anne_hathaway.png" width="70%" style="display: block; margin: auto;" /> --- class: left, middle # Example 1 .pull-left[ * What is the story the graph is telling? * What are the variables here? * What **geom** are the variables map to? * What are the **aesthetic**s of the **geom**? + Which variable sets the value of that **aesthetic**? * What additional context does this graphic provide? ] .pull-right[  ] --- class: left, middle # Example 2 <img src="img/harassment_graphic.png" width="65%" style="display: block; margin: auto;" /> --- class: left, middle # Example 2 .pull-left[ * What is the story the graph is telling? * What are the variables here? * What **geom** are the variables map to? * What are the **aesthetic**s of the **geom**? + Which variable sets the value of that **aesthetic**? * What additional context does this graphic provide? ] .pull-right[  ] --- class: left, middle # Example 3 <img src="img/pdx_weather.png" width="90%" style="display: block; margin: auto;" /> --- class: left, middle # Example 3 .pull-left[ * What is the story the graph is telling? * What are the variables here? * What **geom** are the variables map to? * What are the **aesthetic**s of the **geom**? + Which variable sets the value of that **aesthetic**? * What additional context does this graphic provide? ] .pull-right[  ] --- class: left, middle # Example 4 <img src="img/covid_govt.png" width="90%" style="display: block; margin: auto;" /> --- class: left, middle # Example 4 .pull-left[ * What is the story the graph is telling? * What are the variables here? * What **geom** are the variables map to? * What are the **aesthetic**s of the **geom**? + Which variable sets the value of that **aesthetic**? * What additional context does this graphic provide? ] .pull-right[  ] --- # Best Practices: Context * Think about the story/questions your visualization answers. * Determine what context/background information your viewer needs. * Include + Axis labels (with units reported) + Legends. + Data source. * Visualizing data involves editorial choices + What to highlight + What colors to use --- # Context Example <img src="img/moma_size.png" width="90%" style="display: block; margin: auto;" /> --- ### Best Practices: Order of perception * Position, length, angle, direction, shape, area, volume, shade, color <div class="figure" style="text-align: center"> <img src="img/visual_cues.png" alt="Yau (2013)" width="40%" /> <p class="caption">Yau (2013)</p> </div> --- # Best Practices: Be careful with color. * Color blindness * Color palettes: sequential, diverging, qualitative --- # Color Palettes: Sequential <img src="img/dude.png" width="80%" style="display: block; margin: auto;" /> * [Dude map](https://qz.com/316906/the-dude-map-how-american-men-refer-to-their-bros/) * Note: Maps are also a great way to provide context! --- # Color Palettes: Diverging <img src="img/pdx_weather.png" width="90%" style="display: block; margin: auto;" /> --- # Color Hue: Qualitative <img src="img/anne_hathaway.png" width="70%" style="display: block; margin: auto;" /> --- # Additional Consideration * Aspect ratio affects our perception of the rate of change <div class="figure" style="text-align: center"> <img src="img/aspect_ratio.png" alt="http://socviz.co/lookatdata.html" width="80%" /> <p class="caption">http://socviz.co/lookatdata.html</p> </div> --- ## Many Ways To Visually Tell A Story Washington Post's Approach: <img src="img/wp_shooter.png" width="70%" style="display: block; margin: auto;" /> [Periscopic's Approach](https://guns.periscopic.com/?year=2013) --- ## Bad Graphics * It is much easier to make a bad graph than a good graph. <div class="figure" style="text-align: center"> <img src="img/pizza_pie.png" alt="YouGov" width="50%" /> <p class="caption">YouGov</p> </div> --- ## Misleading Graphics * Ethical data viz: Be careful that your editorial choices don't make your viewer make incorrect conclusions about the data <div class="figure" style="text-align: center"> <img src="img/FLguns.jpg" alt="Modern Data Science with R" width="70%" /> <p class="caption">Modern Data Science with R</p> </div> --- ## Misleading Graphics * Ethical data viz: Be careful that your editorial choices don't make your viewer make incorrect conclusions about the data <div class="figure" style="text-align: center"> <img src="img/GAcovid.jpg" alt="Georgia Dept of Health" width="70%" /> <p class="caption">Georgia Dept of Health</p> </div> --- ## Misleading Graphics * Choose encodings wisely <div class="figure" style="text-align: center"> <img src="img/GAcovid2.jpg" alt="Georgia Dept of Health" width="70%" /> <p class="caption">Georgia Dept of Health</p> </div> --- ## Misleading Graphics * Choose encodings wisely <div class="figure" style="text-align: center"> <img src="img/GAcovid_cairo.png" alt="Alberto Cairo" width="70%" /> <p class="caption">Alberto Cairo</p> </div> --- ## Summary Thoughts on Graphics * Good graphics are one's where the findings and insights are obvious to the viewer. + You have power over the patterns your viewer sees and the conclusions they draw. Use that power ethically. * Facilitate comparisons. * Add information and key context. * Data visualizations are not neutral. * You have ethical obligations to recognize * It is easier to see the differences and similarities between different types of graphics if we learn the grammar of graphics. * Practicing **decomposing** graphics should make it easier for us to **compose** our own graphics.