How to Choose a Chart

1 downloads 0 Views 810KB Size Report
May 26, 2017 - Choosing the right chart to represent your data can be a daunting .... bar chart. Group A. Group B categorical count conditional bar chart count.
How to Choose a Chart A Statistically Motivated Guide

Andy Grogan-Kaylor May 26, 2017

How to Choose a Chart Choosing the right chart to represent your data can be a daunting process. I believe that a starting point for this thinking is some basic statistical thinking about the type of variables that you have. At the broadest level, variables may be conceptualized as categorical variables, or continuous variables. • categorical variables represent unordered categories like gender, or religious affiliation. • continuous variables represent a continuous scale like a mental health scale, or a measure of neighborhood quality. Once we have discerned the type of variable that have, there are two followup questions we may ask before deciding upon a chart strategy: • Is our graph about one thing at a time? – How much of x is there? – What is the distribution of x? • Is our graph about two things at a time? – What is the relationship of x and y? – How are x and y associated?

A Few Notes A Note About Graph Labels Graphs should have clear titles and labels.

1

Informative Title some other piece of information

Maybe The Title Is Even Your Main Takeaway 1.02 1.01 1.00 0.99 0.98

120

possibly informative key takeaway

110 100 90

informative label goes here

80

Words should be spelled out. Every extra 'dimension' should convey information.

A Note About Software The principles of graphing discussed in this document transcend any particular software package, and could be implemented in many different software packages. The graphs in these particular examples use ggplot2, a graphing library in R. ggplot2 graph syntax can be formidably complex, with a somewhat steep learning curve. More information about ggplot can be found here.

A Note About Graph Colors This document uses colors based upon official University of Michigan colors. Using colors that match the design scheme of your organization may be helpful.

A Simulated Data File of Continuous and Categorical Data The first few observations… x

y

z

u

v

w

66.77 79.99 73.84 188.3 131.5 117.8

107.5 107.2 122.5 295.6 111.9 103

83.95 143 122.2 118.9 76.81 106.8

Group A Group A Group A Group A Group A Group A

Group A Group A Group A Group A Group A Group A

Group A Group A Group A Group B Group A Group A

2

One Thing At A Time

Two Things At A Time

Continuous

Continuous By Categorical

histogram

conditional histogram

150

Group A 100

100

50

count

count

150

50

0

Group B 150 100 50

0

0

0

100

200

300

0

100

continuous

200

density

conditional density Group A

0.008

density

density

0.012

0.004 0.000 100

200

0.015 0.010 0.005 0.000

Group B 0.015 0.010 0.005 0.000

300

100

continuous

200 100

300

conditional boxplot continuous

300

200

continuous

boxplot continuous

300

continuous

300 200 100 Group A

Group B

categorical

150 100 50 0

mean of continuous

mean of continuous

barchart of mean 200

conditional barchart of means 200 150 100 50 0 Group A

Group B

categorical

3

violin plot

conditional violin plot Group A

continuous

continuous

300 200 100

Group B

300 200 100

categorical

dotplot

conditional dotplot Group A

0.75

density

density

1.00

0.50 0.25 0.00 100

200

1.00 0.75 0.50 0.25 0.00

Group B 1.00 0.75 0.50 0.25 0.00

300

100

continuous

200

300

continuous

One Thing At A Time

Two Things At A Time

Categorical

Categorical By Categorical

bar chart

conditional bar chart Group B

count

count

Group A

categorical

categorical

horizontal bar chart

conditional horizontal bar chart categorical

categorical

Group A

Group B

count

count

4

pie chart

conditional pie chart Group A

Group B

categorical

categorical

doughnut chart

conditional doughnut chart Group A

categorical

Group B

categorical

Continuous by Continuous scatterplot with fit line continuous

continuous

scatterplot

continuous

continuous

smoother count 20 15 10 5

continuous

continuous

hexagon plot

continuous

continuous

5

area plot

contour plot level continuous

continuous

0.00016 0.00012 0.00008 0.00004

continuous

continuous

Graphics made with the ggplot2 graphing library created by Hadley Wickham. Available online at https://agroganweb.wordpress.com/data-visualization-dataviz/

How to Choose a Chart by Andrew Grogan-Kaylor is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. You are welcome to download and use this handout in your own classes, or work, as long as the handout remains properly attributed. Last updated: May 26 2017 at 15:10

6