matplotlib: up and running (pycon canada 2015)
TRANSCRIPT
![Page 1: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/1.jpg)
UP AND RUNNINGMATPLOTLIB
![Page 2: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/2.jpg)
Hi
![Page 3: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/3.jpg)
OUTLINE
▸ Understanding matplotlib
▸ History of matplotlib
▸ The Anatomy of maptlotlib
▸ The Interfaces of matplotlib
▸ Overview of the pyplot interface
▸ Uses for matplotlib
![Page 4: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/4.jpg)
HISTORYMATPLOTLIB
![Page 5: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/5.jpg)
JOHN HUNTER (1968 - 2012)
![Page 6: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/6.jpg)
THE DONGLE PROBLEM
![Page 7: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/7.jpg)
MATPLOTLIB (1.0)
▸ Was meant to be an alternative to MATLAB
▸ Created by John Hunter for examining data from epileptic patients
![Page 8: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/8.jpg)
MATPLOTLIBTHE ANATOMY OF
![Page 9: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/9.jpg)
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
![Page 10: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/10.jpg)
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
![Page 11: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/11.jpg)
THE INTERFACESMATPLOTLIB
![Page 12: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/12.jpg)
THREE INTERFACES OF MATPLOTLIB
▸ pylab (deprecated)
▸ pyplot
▸ The Object-Oriented API
![Page 13: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/13.jpg)
PYLAB
▸ Pros
▸ Least verbose
▸ Cons
▸ Imports everything into global space
▸ When?
▸ It’s deprecated
▸ Ok, fine, one-off, “throwaway” code only!
![Page 14: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/14.jpg)
PYPLOT
▸ Pros
▸ Namespaces!
▸ Cons
▸ Less control
▸ When?
▸ Interactive data exploration
▸ Small batch visualizations
![Page 15: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/15.jpg)
THE OBJECT-ORIENTED API
▸ Pros
▸ Total control
▸ Cons
▸ Syntactically heavy
▸ When?
▸ Embedding
▸ Large batch visualizations
![Page 16: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/16.jpg)
THE SCRIPTING INTERFACEMATPLOTLIB
![Page 17: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/17.jpg)
PYLOT
▸ MATLAB-like
▸ procedural
▸ stateful
![Page 18: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/18.jpg)
STATEFUL INTERFACE
plt.plot(x, y) plt.gca() plt.gcf()
FIGURE 1
FIGURE 2
FIGURE 3
FIGURE 3
fig.clf()
![Page 19: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/19.jpg)
DEMO TIME
![Page 20: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/20.jpg)
MATPLOTLIB 1.5.0 IS OUT -- STILL ALIVE AN[D] KICKING WITH PANDAS DATAFRAME SUPPORT AND PRETTY SEABORN STYLES
rasbt - r/Python
![Page 21: Matplotlib: Up and Running (PyCon Canada 2015)](https://reader034.vdocument.in/reader034/viewer/2022042517/589d75c51a28ab69538b4d19/html5/thumbnails/21.jpg)
THE FUTURE
▸ Modern Libraries
▸ Seaborn
▸ ggplot
▸ mpld3 and bokeh (for the web)
▸ Spyre
▸ New (and Custom) styles