--- title: "2.3: Data Visualization" author: "Ellen Bledsoe, Lily McMullen" format: html: toc: true --- ```{r} #| include: false knitr::opts_chunk$set(echo = TRUE) ``` # A Visualization Primer ## Learning Outcomes - Students will be able to explain why data visualization is important. - Students will be able to identify different types of data visualizations and describe when each is appropriate. - Students will be able to match a dataset's structure to an appropriate visualization type. - Students will be able to critique a visualization. ## Why Does Data Visualization Matter? ### Small Groups As a group, take 5 minutes to compare your notes and come to a group consensus on your top 3 reasons why data visualization matters. Be sure to choose someone to report out! ::: instructor-only **Instructor Note:** Some strong answers include: patterns in data become visible that are invisible in a table; complex information can be communicated quickly; visualizations help identify outliers and anomalies; they are essential for communicating findings to non-technical audiences; and they support exploratory data analysis before formal testing. ::: ## Types of Visualization ### Visual cues for communicating data [Here](https://rafalab.dfci.harvard.edu/dsbook-part-1/dataviz/dataviz-principles.html) is a decent overview of some of the core concepts of data visualization. This website is pretty great and goes into a lot of detail about good practices in data visualization. If this is something that really piques your interest, it is well worth exploring further! In this course, our main take-away from this website is the use of visual cues to communicate data and which ones are better than others. ![](assets/data_viz_cues.jpg){width="50%"} ### Small group activity In groups, discuss as many types of visualizations as you can think of. It's okay if you don't know what they are called! Make a quick list or draw them out if you prefer. [This website](https://www.data-to-viz.com/) is an amazing reference for data visualization methods and when to use what. It also has examples of each type plotted in `ggplot2`. We will talk more about how to choose the right visualization for your data now and also in the rest of the module. ::: instructor-only **Instructor Note:** Students commonly name: bar charts, pie charts, line graphs, scatter plots, histograms. Accept any reasonable answer and write them on the board (if you have one). ::: ### Data matching activity Complete the data matching activity with your group. Your instructor will provide the worksheet. Spend a few minutes seeing if you can match the data descriptions to the types of data visualizations. Each “dataset” is pulled from the same overall dataset: measurements from 344 individual penguins from different species and on different islands over 3 years. Some datasets created multiple plots. #### Data descriptions A. Penguin body mass and flipper lengths B. Penguin flipper lengths C. Penguin species and flipper lengths D. Penguins body mass, species, and flipper lengths ::: instructor-only **Answers:** 1. A 2. C 3. C 4. B 5. C 6. D ::: ## Figure Critique First, read through [this blog post](https://humansofdata.atlan.com/2019/02/dos-donts-data-visualization/) on the "Dos and Don'ts of Data Visualization" Now that you have some insights, let's critique these figures below. Yes, these are actual figures in the wild! For each one, consider: - What aspects don't work? - What aspects do work? - How would you present this data differently? **Figure 1:** ![](assets/image1.png){width="50%"} **Figure 2:** ![](assets/image2.jpg){width="50%"} **Figure 3:** ![](assets/image3.jpg){width="50%"} **Figure 4:** ![](assets/image4.png){width="50%"} ::: instructor-only **Instructor Note:** These figures share several problems that are worth talking about: - Truncated axes exaggerate differences by not starting the y-axis at zero. The GNH gender gap looks dramatic visually but is only 0.079 on a 0-1 scale. - Pie charts make proportion comparison difficult because humans are poor at judging angles. A bar chart is almost always clearer. - 3D effects are adding visual distortion without adding information. 3D bars and cylinders make it impossible to accurately read values off an axis. - Showing too many groups in the same overlapping plot makes it impossible to find meaning from any of them. - Bins of unequal length in a histogram. :::