1 of 18

Lecture 7

Charts

DATA 8

Fall 2023

2 of 18

Announcements

  • HW 3 has been released and is due Wednesday (9/13)
    • Submit by Tuesday at 11pm for extra credit
  • Lab 3 is due tonight at 11pm

3 of 18

Weekly Goals

  • Wednesday
    • Table review
    • Working with Census data
  • Today
    • Visualizing data
    • Distributions

4 of 18

Attribute Types

5 of 18

Types of Attributes

All values in a column of a table should be both the same type and be comparable to each other in some way

  • Numerical — Each value is from a numerical scale
    • Numerical measurements are ordered
    • Differences are meaningful
  • Categorical — Each value is from a fixed inventory
    • May or may not have an ordering
      • Examples of ordered categorical values?
    • Categories are the same or different

6 of 18

“Numerical” Attributes

Just because the values are numbers, doesn’t mean the attribute is numerical

  • Census example has numerical SEX code (0, 1, and 2)

  • It doesn’t make sense to perform arithmetic on these “numbers”, e.g. (0+1+2)/3 is meaningless

  • The attribute SEX is still categorical, even though numbers were used for the categories

7 of 18

Numerical Data

8 of 18

Plotting Two Numerical Variables

Line plot: plot

Scatter plot : scatter

(Demo)

9 of 18

https://en.wikipedia.org/wiki/C-3PO

Anthony Daniels,

actor

10 of 18

Line vs Scatter Plot

  • Use line plots for sequential quantitative data: if...
    • ...your x-axis has an order
    • ...sequential differences in y values are meaningful
    • ...there’s only one y-value for each x-value
    • Often: x-axis is time or distance
  • Use scatter plots for non-sequential quantitative data
    • If you are looking for associations

  • t.plot(x_label, y_label)
  • t.scatter(x_label, y_label)

11 of 18

Categorical and Numerical Variables

12 of 18

Highest Grossing Movies as of 2017

(Demo)

13 of 18

How Do You Generate This Chart?

Top 10 highest grossing movies

Number of years since release

14 of 18

Visualization Fundamentals

15 of 18

Don’t Do This

Source: Washington Post

16 of 18

Do This Instead

Source: Ross Ihaka

17 of 18

Good Practices

  • Less can be more
    • Minimize decoration
    • Choose colors carefully
      • Minimize the number of different colors
  • If data are numerical, preserve their relative values and distances between them

See Edward Tufte’s “The Visual Display of Quantitative Information”

18 of 18

Importance of the Y-Axis