1 of 30

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

data6.org/su22/syllabus/#acknowledgements-

2 of 30

Week 2

Announcements!

  • Homework 1 has been released and will be due on 7/15 @ 11 PM
    • Note the deadline extension
    • If you’re having issues accessing the assignment, post on Ed or come to Office Hours
  • Office Hours take place on Tuesdays and Thursdays 1-3 PM in Evans 6
  • Post on Ed if you have questions about particular concepts or assignment questions

2

3 of 30

Today’s Roadmap

Lecture 07, Data 6 Summer 2022

  1. Examples of Visualizations
  2. What is Visualization?
  3. Variable Types
  4. Encoding

3

4 of 30

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

5 of 30

Examples of Visualizations

5

1. Examples of Visualization

2. What is Visualization?

3. Variable Types

4. Encoding

➤

6 of 30

6

A map depicting the town of Konya, Turkey. Supposedly the world’s first map (~6200 BC).

7 of 30

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 of 30

8

Florence Nightingale’s visualization depicting deaths in the Crimean war (1850s).

9 of 30

9

Maya Lin’s Vietnam War Memorial in Washington DC (1982).

10 of 30

10

Daily COVID cases in California, per Google (Summer 2022).

11 of 30

What is Visualization?

11

1. Examples of Visualization

2. What is Visualization?

3. Variable Types

4. Encoding

➤

12 of 30

What is Visualization?

12

13 of 30

Visualizations are for humans

13

“Looks like older people didn’t spend more than younger people.”

...

14 of 30

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

15 of 30

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

The John Hunter Excellence in Plotting Contest.

16 of 30

Variable Types

16

1. Examples of Visualization

2. What is Visualization?

3. Variable Types

4. Encoding

➤

17 of 30

Variable Types

Suppose we have some data and want to create a visualization.

  • Question: How do we know what kind of visualization to create? 🤔
  • Answer: It depends on the type(s) of information we want to visualize.
    • Bar charts work sometimes. But not all the time!

​

Where we are visualizing different variables (features) of a dataset, a lot depends on the type(s) of variables we’re working with:

  • Variable types are different from data types like string, int, Table, etc.
  • In the next few slides we’ll study the different variable feature types, in order to make more informed decisions when creating visualizations.

17

18 of 30

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.

19 of 30

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.

20 of 30

Quick Check 1

Determine the variable feature type of each of the following variables.

  • Fuel economy in miles per gallon.
  • Number of semesters at Berkeley.
  • Class standing (freshman, sophomore, etc.).
  • Income bracket (low, medium, high).
  • Bank account number.

20

Quick Check

21 of 30

Encoding

21

1. Examples of Visualization

2. What is Visualization?

3. Variable Types

4. Encoding

➤

22 of 30

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).

  • Longer bar = higher average age.

22

23 of 30

Quick Check 2

How many variables are being encoded in this plot?

23

Quick Check

24 of 30

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

25 of 30

In Conclusion…

25

26 of 30

Summary

  • It is often easier to discern patterns in our data when we visualize it rather than looking at it in a table.
    • We visualize to further our understanding of our results and to communicate our results with others.
  • There are two main kinds of statistical variable types – numerical and categorical.
    • Numerical variables are either discrete or continuous, while categorical variables are either ordinal or nominal.
    • Categorical variables may be stored as numbers! (area codes)
  • Encodings translate variables into visual properties.
      • Not all encodings work for all variables – we’ll learn more about this soon.

26

27 of 30

Coming Up…

27

28 of 30

Visualization tools

  • Without a computer:
    • Drawing
    • Painting
  • With a computer:
    • Without programming:
      • Photoshop
      • Figma
      • Tableau
    • With programming:
      • matplotlib
      • seaborn
      • plotly
      • D3.js

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.

29 of 30

Recap

Next Time

  • Introduction to Visualization
  • Bar Charts
  • Distributions
  • Customizing Visualizations

​

29

30 of 30

Week 2

Announcements!

  • Homework 1 has been released and will be due on 7/15 @ 11 PM
    • Note the deadline extension
    • If you’re having issues accessing the assignment, post on Ed or come to Office Hours
  • Office Hours take place on Tuesdays and Thursdays 1-3 PM in Evans 6
  • Post on Ed if you have questions about particular concepts or assignment questions

30