class: center, middle, title-slide .title[ # From Data to Visualization 2 ] .author[ ### Claus O. Wilke ] .date[ ### last updated: 2022-06-26 ] --- ## Topics covered -- 1. Visualizing uncertainty -- 2. Visualizing geospatial data --- class: center middle # Let's imagine we're playing a game --- class: center middle # The odds are in your favor:<br>You have a 90% chance of winning! --- class: center middle background-image: url("data-to-visualization-2_files/Disappearing_dots.gif") background-size: contain background-color: #cccccc <style> .move-down { margin-top: -6em; } </style> .move-down[ # playing ] ??? Image by Wikiemdia user [Jahobr](https://commons.wikimedia.org/wiki/User:Jahobr), released into the public domain. https://commons.wikimedia.org/wiki/File:Disappearing_dots.gif --- class: center middle # Sorry, you lost. --- class: center middle # How does that make you feel? --- ## We are bad at judging uncertainty -- * You had a 10% chance of losing -- * One in ten playing this game will lose -- * 90% chance of winning is nowhere near a certain win --- ## It helps to visualize a set of possible outcomes .center[ ![](data-to-visualization-2_files/figure-html/freq-waffle-1.svg)<!-- --> ] Possible outcomes from 100 individual games played --- <br> .center[ ![](data-to-visualization-2_files/figure-html/freq-waffle2-1.svg)<!-- --> ] -- This type of visualization is called "frequency framing" --- ## Visualizing the uncertainty of point estimates -- - A point estimate is a single number, such as a mean -- - Uncertainty is expressed as standard error, confidence interval, or credible interval -- - Important:<br>Don't confuse the uncertainty of a point estimate with the variation in the sample --- ## Key concepts of statistical sampling .center[ ![](data-to-visualization-2_files/figure-html/sampling-schematic1-1.svg)<!-- --> ] ??? Figure redrawn from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- ## Key concepts of statistical sampling .center[ ![](data-to-visualization-2_files/figure-html/sampling-schematic2-1.svg)<!-- --> ] ??? Figure redrawn from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- ## Key concepts of statistical sampling .center[ ![](data-to-visualization-2_files/figure-html/sampling-schematic3-1.svg)<!-- --> ] ??? Figure redrawn from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- ## Frequency interpretation of a confidence interval .center[ <img src = "https://clauswilke.com/dataviz/visualizing_uncertainty_files/figure-html/ci-frequentist-expl-1.png" width = "500" /> ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- ## Example: Highest point reached on Everest in 2019 .center[ ![](data-to-visualization-2_files/figure-html/everest-highest-point-1.svg)<!-- --> ] Includes only climbers and expedition members who **did not** summit --- ## Marginal effects example: Height reached on Everest --- ## Marginal effects example: Height reached on Everest Reference: male climber w/ oxygen who summited and survived -- .center[ ![](data-to-visualization-2_files/figure-html/everest_margins-1.svg)<!-- --> ] Error bars show 95% confidence intervals --- ## Marginal effects example: Height reached on Everest Other visualization options: half-eye .center[ ![](data-to-visualization-2_files/figure-html/everest_margins2-1.svg)<!-- --> ] --- ## Marginal effects example: Height reached on Everest Other visualization options: quantile dotplot .center[ ![](data-to-visualization-2_files/figure-html/everest_margins4-1.svg)<!-- --> ] --- class: center middle ## A quick introduction to geospatial data --- background-image: url("https://clauswilke.com/dataviz/geospatial_data_files/figure-html/world-orthographic-1.png") background-position: left 50% top 75% background-size: 45% ## Parallels (latitude) and meridians (longitude) ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/coordinate_systems_axes_files/figure-html/worldmap-four-projections-1.png") background-position: left 50% top 75% background-size: 65% ## There are many ways to project onto a 2D plane ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/geospatial_data_files/figure-html/world-mercator-1.png") background-position: left 50% top 70% background-size: 45% ## There are many ways to project onto a 2D plane .absolute-bottom-left[ Mercator projection: Shapes are preserved, areas are severely distorted ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/geospatial_data_files/figure-html/world-goode-1.png") background-position: left 50% top 60% background-size: 80% ## There are many ways to project onto a 2D plane .absolute-bottom-left[ Goode homolosine: Areas are preserved, shapes are somewhat distorted ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/geospatial_data_files/figure-html/usa-orthographic-1.png") background-position: left 50% top 60% background-size: 45% ## Projecting the US .absolute-bottom-left[ Alaska, Hawaii, and the lower 48 are far apart; difficult to show on one map ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/geospatial_data_files/figure-html/usa-true-albers-1.png") background-position: left 50% top 60% background-size: 50% ## Projecting the US .absolute-bottom-left[ A fair, area-preserving projection ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/geospatial_data_files/figure-html/usa-albers-1.png") background-position: left 50% top 60% background-size: 50% ## A common visualization. What happened to Alaska? .absolute-bottom-left[ Alaska and Hawaii were moved closer; Alaska was also reduced in size ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/geospatial_data_files/figure-html/usa-albers-revised-1.png") background-position: left 50% top 60% background-size: 50% ## A fair visualization of the 50 states .absolute-bottom-left[ Alaska is the largest state; 2.2 the size of Texas ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) [//]: # "segment ends here" --- class: center middle ## Choropleth mapping: Coloring areas by a data value --- background-image: url("https://clauswilke.com/dataviz/geospatial_data_files/figure-html/population-density-counties-1.png") background-position: left 50% top 60% background-size: 50% ## US population density as a choropleth map .absolute-bottom-left[ Alaska has very low population density ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/geospatial_data_files/figure-html/population-density-counties2-1.png") background-position: left 50% top 60% background-size: 50% ## US population density as a choropleth map .absolute-bottom-left[ Alaska has very low population density ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/geospatial_data_files/figure-html/median-income-counties-binned-1.png") background-position: left 50% top 60% background-size: 50% ## US median income as a choropleth map .absolute-bottom-left[ A binned color scale can make the map more readable ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/geospatial_data_files/figure-html/median-income-states-1.png") background-position: left 50% top 60% background-size: 50% ## Choropleth maps can be misleading .absolute-bottom-left[ Large area of Alaska makes it appear very rich; remember, it's mostly empty ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/geospatial_data_files/figure-html/median-income-statebins-1.png") background-position: left 50% top 60% background-size: 50% ## A cartogram heatmap may be preferable .absolute-bottom-left[ Each state is shown as an equally sized square ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) [//]: # "segment ends here" --- class: center middle ## Maps and layers --- background-image: url("https://clauswilke.com/dataviz/geospatial_data_files/figure-html/sfbay-overview-1.png") background-position: left 50% top 60% background-size: 50% ## Maps show data in a geospatial context .absolute-bottom-left[ Wind turbines in the San Francisco Bay Area ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/geospatial_data_files/figure-html/sfbay-layers-1.png") background-position: left 50% top 60% background-size: 50% ## Maps are composed of several distinct layers .absolute-bottom-left[ Wind turbines in the San Francisco Bay Area ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- background-image: url("https://clauswilke.com/dataviz/geospatial_data_files/figure-html/shiloh-map-1.png") background-position: left 50% top 60% background-size: 50% ## Common visualization: scatterplot on a map background .absolute-bottom-left[ Location of individual wind turbines in the Shiloh Wind Farm ] ??? Figure from [Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.](https://clauswilke.com/dataviz) --- ## Further reading Relevant chapters from Fundamentals of Data Visualization: - [Chapter 15: Visualizing geospatial data](https://clauswilke.com/dataviz/geospatial-data.html) - [Chapter 16: Visualizing uncertainty](https://clauswilke.com/dataviz/visualizing-uncertainty.html)