Introduction to Visualization
1
Data 6 Summer 2022
LECTURE 07
They say a picture is worth a thousand words… right?
Developed by students and faculty at UC Berkeley and Tuskegee University
Week 2
Announcements!
2
Today’s Roadmap
Lecture 07, Data 6 Summer 2022
3
Data 6 Content
4
Module 1
Introduction to Python and Jupyter Notebooks
Module 2
Data Visualization
Module 3
Working with Tables
Module 4
Simulation and Randomness
Examples of Visualizations
5
1. Examples of Visualization
2. What is Visualization?
3. Variable Types
4. Encoding
➤
6
A map depicting the town of Konya, Turkey. Supposedly the world’s first map (~6200 BC).
7
John Snow’s map depicting cholera cases in SoHo, London (1854).
Bars correspond to Cholera cases
This map helped determine that the Broad Street water pump was the source of a massive Cholera outbreak.
8
Florence Nightingale’s visualization depicting deaths in the Crimean war (1850s).
9
Maya Lin’s Vietnam War Memorial in Washington DC (1982).
10
Daily COVID cases in California, per Google (Summer 2022).
What is Visualization?
11
1. Examples of Visualization
2. What is Visualization?
3. Variable Types
4. Encoding
➤
What is Visualization?
12
Visualizations are for humans
13
“Looks like older people didn’t spend more than younger people.”
...
Visualize, then quantify!
These datasets all have several statistical properties in common – means, standard deviations, and correlations – but look very different when plotted.
Visualization complements statistics. You can explore this more in future statistics courses.
14
What’s the point of visualization?
Creating good visualizations is an art as much it is a science; there is often no “correct” way to visualize data.
We must be careful and deliberate when visualizing data, especially if our visualizations are going to be used in the real-world.
15
To further your own understanding of your results.
1
To communicate your results with others.
2
If you want to look at some creative, sophisticated visualizations, see
Variable Types
16
1. Examples of Visualization
2. What is Visualization?
3. Variable Types
4. Encoding
➤
Variable Types
Suppose we have some data and want to create a visualization.
Where we are visualizing different variables (features) of a dataset, a lot depends on the type(s) of variables we’re working with:
17
18
e.g number of cars, number of Cal students
e.g price, temperature, GPA, weight
e.g highest degree attained, Yelp stars
e.g colors, political affiliation
Can do arithmetic with.
Cannot do arithmetic with.
Variable Type
Categorical
aka Qualitative
Numerical
aka Quantitative
Ordinal
Categories with some inherent ordering.
Nominal
Categories with no inherent ordering.
Discrete
Whole numbers; can be counted.
Continuous
Numbers with decimals; often measured.
Example: Area Codes
Just because a variable has numbers for values does not make it numerical.
Similarly, a numerical variable might be stored as a string – in that case, you’ll need to convert the corresponding values to ints or floats, depending on what is appropriate.
19
Warning: a categorical variable can have numbers for values!
Area code is a categorical nominal variable.
While area codes are numbers, you can’t do any arithmetic with them. There’s also no order to area codes.
Quick Check 1
Determine the variable feature type of each of the following variables.
20
Quick Check
Encoding
21
1. Examples of Visualization
2. What is Visualization?
3. Variable Types
4. Encoding
➤
Encoding
An encoding is a mapping from a variable to a visual element.
For instance, in bar charts, length can visually encode a numerical variable (here, the average age).
22
Quick Check 2
How many variables are being encoded in this plot?
23
Quick Check
What’s Wrong?
This graph implies that Swedish cars are “greater” than cars from other countries in some sense, when they’re not.
The variable type determines the types of plots (and hence, encodings) that are appropriate.
Over the next few weeks, we will learn how to create several kinds of plots and learn when each is appropriate.
24
In Conclusion…
25
Summary
26
Coming Up…
27
Visualization tools
There are many Python visualization libraries that integrate well with tables.
28
This is nowhere near a comprehensive list!
Both are popular but less “modern”
Newer, and can create interactive visualizations.
Recap
Next Time
29
Week 2
Announcements!
30