Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Matplotlib

Eitan Lees
September 27, 2019

 Matplotlib

An introduction to the python visualization library Matplotlib

Eitan Lees

September 27, 2019
Tweet

More Decks by Eitan Lees

Other Decks in Research

Transcript

  1. Nicolas P. Rougier: - Researcher in computational cognitive neuroscience, located

    in Bordeaux, France - Inria (the French institute for computer science) - Institute of Neurodegenerative Diseases - Author of several scientific computing books (All Free!) - Python & OpenGL for Scientific Visualization - From Python to Numpy - Scipy Lecture Notes Jake VanderPlas: - Visiting Researcher Google Seattle Office - Former Director of Open Software at the University of Washington’s eScience institute - Contributions made in - Scikit-Learn - SciPy - AstroPy - Altair
  2. Matplotlib was created by John D. Hunter in 2003 to

    visualize electrocorticography data. In a post to the official python mailing list John writes ... My goal is to make high quality, publication quality plotting easy in python, with a syntax familiar to matlab users.
  3. Matplotlib was created by John D. Hunter in 2003 to

    visualize electrocorticography data. In a post to the official python mailing list John writes ... My goal is to make high quality, publication quality plotting easy in python, with a syntax familiar to matlab users. Also motivated later in the post ... * make easy things easy (subplots, lines styles, colors) * make hard things possible (OO interface for full control)
  4. Important Questions: - Do you target desktop or web rendering?

    - Do you need complex 3D rendering? - Do you need publication quality? - Do you have very large data? - Is there an active community? - Are there documentation and tutorials?
  5. Strengths: - Designed like MatLab: switching was easy - Many

    rendering backends - Can reproduce just about any plot (with a bit of effort)
  6. Strengths: - Designed like MatLab: switching was easy - Many

    rendering backends - Can reproduce just about any plot (with a bit of effort) - Well-tested, standard tool for over a decade
  7. Strengths: - Designed like MatLab: switching was easy - Many

    rendering backends - Can reproduce just about any plot (with a bit of effort) - Well-tested, standard tool for over a decade Weaknesses: - API is imperative & often overly verbose - Poor support for web/interactive graphics - Often slow for large & complicated data
  8. Matplotlib is organized in a hierarchy. At the top of

    the hierarchy is the matplotlib "state-machine environment" which is provided by the matplotlib.pyplot module. At this level, simple functions are used to add plot elements (lines, images, text, etc.) to the current axes in the current figure.
  9. Matplotlib is organized in a hierarchy. At the top of

    the hierarchy is the matplotlib "state-machine environment" which is provided by the matplotlib.pyplot module. At this level, simple functions are used to add plot elements (lines, images, text, etc.) to the current axes in the current figure. The next level down in the hierarchy is the first level of the object-oriented interface. At this level, the user uses pyplot to create figures, and axes objects which are then used for most plotting actions.
  10. Matplotlib is organized in a hierarchy. At the top of

    the hierarchy is the matplotlib "state-machine environment" which is provided by the matplotlib.pyplot module. At this level, simple functions are used to add plot elements (lines, images, text, etc.) to the current axes in the current figure. The next level down in the hierarchy is the first level of the object-oriented interface. At this level, the user uses pyplot to create figures, and axes objects which are then used for most plotting actions. At the lowest level matplotlib manages a variety of graphics primitives and engines to render and display figures. ⫶
  11. MATLAB-style Interface Object-Oriented Interface plt.plot(x, y) plt.xlim(-1, 1) plt.title(“My Plot”)

    ... fig = plt.figure() ax = fig.add_axes([0.1,0.1,0.8,0.8]) ax.plot(x, y) ax.set(xlim=(-1, 1), title=”My Plot”) ...
  12. Fast and Convenient Detailed and Powerful plt.plot(x, y) plt.xlim(-1, 1)

    plt.title(“My Plot”) ... fig = plt.figure() ax = fig.add_axes([0.1,0.1,0.8,0.8]) ax.plot(x, y) ax.set(xlim=(-1, 1), title=”My Plot”) ...