day$2:$introduc/on$to$ visualizaons$ - github pagesdataiap.github.io/dataiap/lectures/day2.pdf ·...

46
Day 2: Introduc/on to Visualiza/ons matplotlib

Upload: others

Post on 24-Jul-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Day  2:  Introduc/on  to  Visualiza/ons  

matplotlib  

Page 2: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Summarize  

Page 3: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Complex  

Page 4: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

h=p://www.guardian.co.uk/news/datablog/2011/oct/07/us-­‐jobless-­‐unemployment-­‐data  

Page 5: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

finance.google.com  

Page 6: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

2  

Page 7: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Exploring  

Page 8: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Storytelling  

h=p://www.gapminder.org/  

Page 9: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Anima/on?  

Page 10: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Anima/on?  

ONLY  SOMETIMES  

Page 11: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

“The  Message”  Grandmaster  Flash  (1982)  

Page 12: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

h=p://www.julieelder.com/wp-­‐content/uploads/2010/11/understand_full.jpg  

Page 13: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()
Page 14: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Visualiza/on  !=  Sexy  Pictures  

Page 15: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

h=p://psychcentral.com/blog/archives/2011/06/29/an-­‐epidemic-­‐of-­‐bad-­‐infographics-­‐depression/  

Page 16: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

h=p://www.pitchinterac/ve.com/elec/on2008/jobarcs.html  

Page 17: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

h=p://visualizeit.wordpress.com/category/bad-­‐visualiza/on/  

Page 18: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

The  Basics  

Page 19: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

The  Basics  blog.okcupid.com  

Page 20: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Bar  Graph  

h=p://blog.okcupid.com  

Page 21: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Sca=er  Plot  

h=p://blog.okcupid.com  

Page 22: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Line  Graph  

h=p://blog.okcupid.com  

Page 23: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Choropleth  Plots  

h=p://blog.okcupid.com  

Page 24: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Box  Plots  

Page 25: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

matplotlib  Python’s  version  of  Matlab  plocng  

Page 26: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

How  matplotlib  Draws  

Page 27: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Figure  object  

Figure  

Page 28: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Subplot  object  

Figure  

Draw  in  here   Subplot  

Draw  in  here  

Page 29: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

figure.add_subplot(2,  3,  1)  

2    rows  

3  columns  

Page 30: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

figure.add_subplot(2,  3,  1)  

2    rows  

3  columns  

Page 31: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

figure.add_subplot(2,  3,  1)  

2    rows  

3  columns  

Page 32: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

figure.add_subplot(2,  3,  1)  

2    rows  

3  columns  

1  

Page 33: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Char/ng  Library  

•  subplot.bar()  •  subplot.plot()  •  subplot.sca=er()  •  subplot.boxplot()  

Page 34: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Lines  

Figure  

Subplot  

Page 35: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Boxes  

Figure  

Subplot  

Page 36: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Polygons  

Figure  

Subplot  

Page 37: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Pain/ng  

Page 38: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Overlaps  

Figure  

Subplot  

Page 39: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Overlaps  

Figure  

Subplot  

Page 40: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Choropleth  Plots  

h=p://blog.okcupid.com  

Page 41: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

No  Easy  Way  

Page 42: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

How  Maps  are  Drawn  

Page 43: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

How  Maps  are  Drawn  

Page 44: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

Helper  Func/ons  

draw_county(subplot,  county_id,  color)    

draw_state(subplot,  state,  color)  

FIPS  

Page 45: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

dataiap.github.com/dataiap/day2/  

Page 46: Day$2:$Introduc/on$to$ Visualizaons$ - GitHub Pagesdataiap.github.io/dataiap/lectures/day2.pdf · Char/ng$Library$ • subplot.bar() • subplot.plot() • subplot.scaer • subplot.boxplot()

git