Figure out your �row letter (row) & seat # (column)
Lecture 8
Histograms
DATA 8
Fall 2017
Slides created by John DeNero (denero@berkeley.edu) and Ani Adhikari (adhikari@berkeley.edu)
Announcements
Bar Charts (Review)
Types of Data
All values in a column should be both the same type and be comparable to each other in some way
Bar Charts of Counts
Distributions:
Bar charts can display the distribution of categorical values
(Demo)
Binning
Binning Numerical Values
Binning is counting the number of numerical values that lie within ranges, called bins.
188, 170, 189, 163, 183, 171, 185, 168, 173, ...
160
165
170
175
180
185
190
The [185,190) bin
Histogram
Chart to display the distribution of numerical values using bins
(Demo)
Attendance for Odd Seats
The Density Scale
Histogram Axes
By default, hist uses a scale (normed=True) that ensures the area of the chart sums to 100%
(Demo)
How to Calculate Height
The [20, 40) bin contains 59 out of 200 movies
29.5 percent
Height of bar = --------------------------
20 years
= 1.475 percent per year
Height Measures Density
% in bin
Height = ---------------------
width of bin
(Demo)
Area Measures Percent
Area = % in bin = Height x width of bin
Discussion Question
What's the height of each bar in these �two histograms?
actress.hist(1, bins=[0,15,25,85])
actress.hist(1, bins=[0,15,35,85])
What are the vertical axis units?
Name | 2016 Income (millions) |
Jennifer Lawrence | 61.7 |
Scarlett Johansson | 57.5 |
Angelina Jolie | 40 |
Jennifer Aniston | 24.75 |
Anne Hathaway | 24 |
Melissa McCarthy | 24 |
Bingbing Fan | 20 |
Sandra Bullock | 20 |
Cara Delevingne | 15 |
Reese Witherspoon | 15 |
Amy Adams | 15 |
Kristen Stewart | 12 |
Amanda Seyfried | 10.5 |
Tina Fey | 10.5 |
Julia Roberts | 10 |
Emma Stone | 10 |
Natalie Portman | 8.5 |
Margot Robbie | 8 |
Meryl Streep | 6 |
Mila Kunis | 4.5 |
Attendance for Even Seats
Chart Types
Bar Chart Versus Histogram
Bar Chart
Histogram
Overlaid Graphs
For visually comparing two populations
(Demo)