Upload
christopher-roach
View
462
Download
1
Embed Size (px)
Citation preview
UP AND RUNNINGMATPLOTLIB
Hi
OUTLINE
▸ Understanding matplotlib
▸ History of matplotlib
▸ The Anatomy of maptlotlib
▸ The Interfaces of matplotlib
▸ Overview of the pyplot interface
▸ Uses for matplotlib
HISTORYMATPLOTLIB
JOHN HUNTER (1968 - 2012)
THE DONGLE PROBLEM
MATPLOTLIB (1.0)
▸ Was meant to be an alternative to MATLAB
▸ Created by John Hunter for examining data from epileptic patients
MATPLOTLIBTHE ANATOMY OF
ANATOMY OF A GRAPHIC
▸ The Figure contains and manages all elements in a graphic
▸ Key architectural decision was to separate the Figure from the act of rendering
THREE DISTINCT LAYERS
▸ Scripting Layer (pyplot)
▸ Artist Layer
▸ Everything in a graphic is an Artist
▸ Knows how to “draw” itself
▸ Backend Layer
▸ Presents a generic drawing interface (e.g., draw_point, draw_line, etc.)
▸ Interacts with the “physical” world
BACKEND LAYER
SCRIPTING LAYER
ARTIST LAYER
THE INTERFACESMATPLOTLIB
THREE INTERFACES OF MATPLOTLIB
▸ pylab (deprecated)
▸ pyplot
▸ The Object-Oriented API
PYLAB
▸ Pros
▸ Least verbose
▸ Cons
▸ Imports everything into global space
▸ When?
▸ It’s deprecated
▸ Ok, fine, one-off, “throwaway” code only!
PYPLOT
▸ Pros
▸ Namespaces!
▸ Cons
▸ Less control
▸ When?
▸ Interactive data exploration
▸ Small batch visualizations
THE OBJECT-ORIENTED API
▸ Pros
▸ Total control
▸ Cons
▸ Syntactically heavy
▸ When?
▸ Embedding
▸ Large batch visualizations
THE SCRIPTING INTERFACEMATPLOTLIB
PYLOT
▸ MATLAB-like
▸ procedural
▸ stateful
STATEFUL INTERFACE
plt.plot(x, y) plt.gca() plt.gcf()
FIGURE 1
FIGURE 2
FIGURE 3
FIGURE 3
fig.clf()
DEMO TIME
MATPLOTLIB 1.5.0 IS OUT -- STILL ALIVE AN[D] KICKING WITH PANDAS DATAFRAME SUPPORT AND PRETTY SEABORN STYLES
rasbt - r/Python
THE FUTURE
▸ Modern Libraries
▸ Seaborn
▸ ggplot
▸ mpld3 and bokeh (for the web)
▸ Spyre
▸ New (and Custom) styles