Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
2nd Python Bootcamp IAG - Displaying Data
Search
Bruno Quint
April 14, 2017
Programming
0
47
2nd Python Bootcamp IAG - Displaying Data
Bruno Quint
April 14, 2017
Tweet
Share
More Decks by Bruno Quint
See All by Bruno Quint
2nd Python Bootcamp IAG - Basics II
b1quint
0
67
2nd Python Bootcamp IAG - Pretty and Healthy
b1quint
0
180
2nd Python Bootcamp IAG - Toolboxes
b1quint
0
47
2nd Python Bootcamp IAG - Basics I
b1quint
0
59
Other Decks in Programming
See All in Programming
ViewファーストなRailsアプリ開発のたのしさ
sugiwe
0
430
モデル駆動設計をやってみようワークショップ開催報告(Modeling Forum2025) / model driven design workshop report
haru860
0
260
Navigation 3: 적응형 UI를 위한 앱 탐색
fornewid
1
220
大体よく分かるscala.collection.immutable.HashMap ~ Compressed Hash-Array Mapped Prefix-tree (CHAMP) ~
matsu_chara
1
210
ソフトウェア設計の課題・原則・実践技法
masuda220
PRO
26
22k
テストやOSS開発に役立つSetup PHP Action
matsuo_atsushi
0
150
エディターってAIで操作できるんだぜ
kis9a
0
700
sbt 2
xuwei_k
0
260
ID管理機能開発の裏側 高速にSaaS連携を実現したチームのAI活用編
atzzcokek
0
210
30分でDoctrineの仕組みと使い方を完全にマスターする / phpconkagawa 2025 Doctrine
ttskch
3
800
ハイパーメディア駆動アプリケーションとIslandアーキテクチャ: htmxによるWebアプリケーション開発と動的UIの局所的適用
nowaki28
0
390
안드로이드 9년차 개발자, 프론트엔드 주니어로 커리어 리셋하기
maryang
1
110
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.3k
A Tale of Four Properties
chriscoyier
162
23k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
1
93
Typedesign – Prime Four
hannesfritz
42
2.9k
Raft: Consensus for Rubyists
vanstee
141
7.2k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.5k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.8k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.8k
Context Engineering - Making Every Token Count
addyosmani
9
490
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
390
Transcript
Python Bootcamp Data Display with MatPlotLib PhD Bruno C. Quint
[email protected]
Resident Astronomer at SOAR Telescope https://github.com/b1quint/PythonBootcamp2017
Table of Contents Feb 14, 2017 Python Bootcamp – Data
Display 2 • A simple plot • Types of plots • Different styles
A simple plot My First Example Feb 14, 2017 Python
Bootcamp – Data Display 3 from matplotlib.pyplot import * x = [0, 1, 2, 3, 4] y = [4, 1, 0, 1, 4] plot(x, y) show()
A simple plot Save the Image! Feb 14, 2017 Python
Bootcamp – Data Display 4 from matplotlib.pyplot import * x = [0, 1, 2, 3, 4] y = [4, 1, 0, 1, 4] plot(x, y) savefig(‘plot_001A.png’)
A simple plot Save the Image! Feb 14, 2017 Python
Bootcamp – Data Display 5 from matplotlib.pyplot import * x = [0, 1, 2, 3, 4] y = [4, 1, 0, 1, 4] plot(x, y) savefig(‘plot_001A.png’, dpi=96)
A simple plot Let’s do it the “right” way Feb
14, 2017 Python Bootcamp – Data Display 6 import matplotlib.pyplot as plt x = [0, 1, 2, 3, 4] y = [4, 1, 0, 1, 4] plt.plot(x, y) plt.show()
A simple plot Let’s do it the “right” way Feb
14, 2017 Python Bootcamp – Data Display 7 import matplotlib.pyplot as plt import numpy as np x = np.arange(5) y = (x – 2) ** 2 plt.plot(x, y) plt.show()
Feb 14, 2017 Python Bootcamp – Data Display 8 x
= np.arange(5) y = x ** 2 – 4 * x + 4 A simple plot Plot and plot again… plt.plot(x, y)
Feb 14, 2017 Python Bootcamp – Data Display 9 x
= np.arange(5) y = x ** 2 – 4 * x + 4 A simple plot Plot and plot again… plt.plot(x, y) plt.plot(x, y)
Feb 14, 2017 Python Bootcamp – Data Display 10 x
= np.arange(5) y = x ** 2 – 4 * x + 4 A simple plot Plot and plot again… plt.plot(x, y) plt.plot(x, y) plt.plot(x, y)
A simple plot Let’s do it the “right” way Feb
14, 2017 Python Bootcamp – Data Display 11 import matplotlib.pyplot as plt import numpy as np x = np.arange(-5, 5, 0.1) y = (x – 2) ** 2 plt.plot(x, y) plt.show()
A simple plot Let’s do it the “right” way Feb
14, 2017 Python Bootcamp – Data Display 12 import matplotlib.pyplot as plt import numpy as np x = np.linspace(-5, 5, 100) y = (x – 2) ** 2 plt.plot(x, y) plt.show()
Feb 14, 2017 Python Bootcamp – Data Display 13 A
simple plot Plot with style def f(t): return (t - 2) ** 2
Feb 14, 2017 Python Bootcamp – Data Display 14 A
simple plot Plot with style def f(t): return (t - 2) ** 2 t1 = np.arange(0.0, 5.0, 0.5) t2 = np.arange(0.0, 5.0, 0.02)
Feb 14, 2017 Python Bootcamp – Data Display 15 A
simple plot Plot with style def f(t): return (t - 2) ** 2 t1 = np.arange(0.0, 5.0, 0.5) t2 = np.arange(0.0, 5.0, 0.02) plt.plot(t1, f(t1), 'ro’) plt.plot(t2, f(t2), 'k')
Feb 14, 2017 Python Bootcamp – Data Display 16 A
simple plot Plot with style def f(t): return (t - 2) ** 2 t1 = np.arange(0.0, 5.0, 0.5) t2 = np.arange(0.0, 5.0, 0.02) plt.plot(t1, f(t1), 'ro', t2, f(t2), 'k')
Feb 14, 2017 Python Bootcamp – Data Display 17 A
simple plot Plot with style def f(t): return (t - 2) ** 2 t1 = np.arange(0.0, 5.0, 0.5) t2 = np.arange(0.0, 5.0, 0.02) plt.plot(t1, f(t1), 'ro’, t2, f(t2), 'k')
Feb 14, 2017 Python Bootcamp – Data Display 18 A
simple plot Plot with style def f(t): return (t - 2) ** 2 t1 = np.arange(0.0, 5.0, 0.5) t2 = np.arange(0.0, 5.0, 0.02) plt.plot(t1, f(t1), 'ro', t2, f(t2), 'k')
Feb 14, 2017 Python Bootcamp – Data Display 19 A
simple plot Plot with style def f(t): return (t - 2) ** 2 t1 = np.arange(0.0, 5.0, 0.5) t2 = np.arange(0.0, 5.0, 0.02) plt.plot(t1, f(t1), 'ro', t2, f(t2), 'k') plt.xlabel(“t [s]”)
plt.xlabel(“t [s]”) Feb 14, 2017 Python Bootcamp – Data Display
20 A simple plot Plot with style def f(t): return (t - 2) ** 2 t1 = np.arange(0.0, 5.0, 0.5) t2 = np.arange(0.0, 5.0, 0.02) plt.plot(t1, f(t1), 'ro', t2, f(t2), 'k')
plt.xlabel(“t [s]”) Feb 14, 2017 Python Bootcamp – Data Display
21 A simple plot Plot with style def f(t): return (t - 2) ** 2 t1 = np.arange(0.0, 5.0, 0.5) t2 = np.arange(0.0, 5.0, 0.02) plt.plot(t1, f(t1), 'ro', t2, f(t2), 'k') plt.ylabel(u"f(t) = (t – 2)$^2$")
plt.xlabel(“t [s]”) Feb 14, 2017 Python Bootcamp – Data Display
22 A simple plot Plot with style def f(t): return (t - 2) ** 2 t1 = np.arange(0.0, 5.0, 0.5) t2 = np.arange(0.0, 5.0, 0.02) plt.plot(t1, f(t1), 'ro', t2, f(t2), 'k') plt.ylabel(u"f(t) = (t – 2)$^2$")
plt.xlabel(“t [s]”, fontsize=24) Feb 14, 2017 Python Bootcamp – Data
Display 23 A simple plot Plot with style def f(t): return (t - 2) ** 2 t1 = np.arange(0.0, 5.0, 0.5) t2 = np.arange(0.0, 5.0, 0.02) plt.plot(t1, f(t1), 'ro', t2, f(t2), 'k') plt.ylabel(u"f(t) = (t – 2)$^2$”, fontsize=24)
plt.xlabel(“t [s]”, fontsize=24) Feb 14, 2017 Python Bootcamp – Data
Display 24 A simple plot Plot with style def f(t): return (t - 2) ** 2 t1 = np.arange(0.0, 5.0, 0.5) t2 = np.arange(0.0, 5.0, 0.02) plt.plot(t1, f(t1), 'ro', t2, f(t2), 'k') plt.ylabel(u"f(t) = (t – 2)$^2$”, fontsize=24)
plt.xlabel(“t [s]”, fontsize=24) Feb 14, 2017 Python Bootcamp – Data
Display 25 A simple plot Plot with style def f(t): return (t - 2) ** 2 t1 = np.arange(0.0, 5.0, 0.5) t2 = np.arange(0.0, 5.0, 0.02) plt.plot(t1, f(t1), 'ro', t2, f(t2), 'k') plt.ylabel(u"f(t) = (t – 2)$^2$”, fontsize=24) plt.xticks(fontsize=18)
plt.xlabel(“t [s]”, fontsize=24) Feb 14, 2017 Python Bootcamp – Data
Display 26 A simple plot Plot with style def f(t): return (t - 2) ** 2 t1 = np.arange(0.0, 5.0, 0.5) t2 = np.arange(0.0, 5.0, 0.02) plt.plot(t1, f(t1), 'ro', t2, f(t2), 'k') plt.ylabel(u"f(t) = (t – 2)$^2$”, fontsize=24)
Feb 14, 2017 Python Bootcamp – Data Display 27 A
simple plot Plot with style >>> import matplotlib as mpl >>> print mpl.rcParams['font.size'] 10 >>> mpl.rcParams['font.size'] = 18 >>> plt.plot(t1, f(t1), 'ro') >>> plt.plot(t2, f(t2), 'k') >>> plt.xlabel('t [s]') >>> plt.ylabel(u’f(t) = (t – 2)$^s$’)
Feb 14, 2017 Python Bootcamp – Data Display 28 A
simple plot Plot with style >>> import matplotlib as mpl >>> print mpl.rcParams['font.size'] 10 >>> mpl.rcParams['font.size'] = 18 >>> plt.plot(t1, f(t1), 'ro') >>> plt.plot(t2, f(t2), 'k') >>> plt.xlabel('t [s]') >>> plt.ylabel(u’f(t) = (t – 2)$^s$’)
Feb 14, 2017 Python Bootcamp – Data Display 29 A
simple plot Plot with style >>> plt.title(“A simple plot”)
Feb 14, 2017 Python Bootcamp – Data Display 30 A
simple plot Plot with style >>> plt.title(“A simple plot”)
Feb 14, 2017 Python Bootcamp – Data Display 31 A
simple plot Plot with style >>> plt.grid()
Feb 14, 2017 Python Bootcamp – Data Display 32 A
simple plot Plot with style >>> plt.grid()
Feb 14, 2017 Python Bootcamp – Data Display 33 A
simple plot Plot with style >>> plt.plot(t1, f(t1), 'ro', label="Points") >>> plt.plot(t2, f(t2), 'k', label="Line") >>> plt.legend()
Feb 14, 2017 Python Bootcamp – Data Display 34 A
simple plot Plot with style >>> plt.plot(t1, f(t1), 'ro', label="Points") >>> plt.plot(t2, f(t2), 'k', label="Line") >>> plt.legend()
Feb 14, 2017 Python Bootcamp – Data Display 35 A
simple plot Plot with style >>> plt.plot(t1, f(t1), 'ro', label="Points") >>> plt.plot(t2, f(t2), 'k', label="Line") >>> plt.legend()
Feb 14, 2017 Python Bootcamp – Data Display 36 A
simple plot Plot with style >>> plt.tight_layout()
Feb 14, 2017 Python Bootcamp – Data Display 37 A
simple plot Plot with style >>> plt.tight_layout()
Feb 14, 2017 Python Bootcamp – Data Display 38 A
good practice x = np.arange(5) - 2 y = x ** 2 fig = plt.figure() ax = fig.add_subplot(111) ax.plot(x, y, ‘o’) ax.set_xlim(-3, 3) ax.set_xlim(-1, 5) plt.show()
Feb 14, 2017 Python Bootcamp – Data Display 39 Some
advanced MatPlotLib x = np.arange(5) - 2 y = x ** 2 fig = plt.figure() ax = fig.add_subplot(111) ax.plot(x, y, ‘o’) ax.set_xlim(-3, 3) ax.set_xlim(-1, 5) plt.show()
Feb 14, 2017 Python Bootcamp – Data Display 40 Some
advanced MatPlotLib x = np.arange(5) - 2 y = x ** 2 fig = plt.figure() ax = fig.add_subplot(111) ax.plot(x, y, ‘o’) ax.set_xlim(-3, 3) ax.set_xlim(-1, 5) plt.show()
Feb 14, 2017 Python Bootcamp – Data Display 41 Types
of plots Scatter Plot Histogram Errorbar Plots Multiple Axis
Feb 14, 2017 Python Bootcamp – Data Display 42 Types
of plots Pie Plots Polar Plots Display Images Stream Plots
Feb 14, 2017 Python Bootcamp – Data Display 43 Types
of plots Plots 3D Contour Plots
Feb 14, 2017 Python Bootcamp – Data Display 44 Different
Styles Default
Feb 14, 2017 Python Bootcamp – Data Display 45 Different
Styles bmh
Feb 14, 2017 Python Bootcamp – Data Display 46 Different
Styles ggplot
Feb 14, 2017 Python Bootcamp – Data Display 47 Different
Styles grayscale
Feb 14, 2017 Python Bootcamp – Data Display 48 Different
Styles seaborn-ticks
Feb 14, 2017 Python Bootcamp – Data Display 49 Different
Styles seaborn-colorblind
Feb 14, 2017 Python Bootcamp – Data Display 50 Colormaps
jet
Feb 14, 2017 Python Bootcamp – Data Display 51 Colormaps
grayscale
Feb 14, 2017 Python Bootcamp – Data Display 52 Colormaps
cubehelix
Feb 14, 2017 Python Bootcamp – Data Display 53 Colormaps
viridis
Feb 14, 2017 Python Bootcamp – Data Display 54 Colormaps
RdYlBu
Questions?