Matplotlib

170b760e0147792d0140e59ec78e9893?s=47 Eitan Lees
September 27, 2019

 Matplotlib

An introduction to the python visualization library Matplotlib

170b760e0147792d0140e59ec78e9893?s=128

Eitan Lees

September 27, 2019
Tweet

Transcript

  1. None
  2. 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
  3. None
  4. Part One: The Origin Story

  5. 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.
  6. 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)
  7. Matplotlib Development Timeline

  8. The Python Visualization Landscape

  9. 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?
  10. None
  11. None
  12. None
  13. Strengths: - Designed like MatLab: switching was easy

  14. Strengths: - Designed like MatLab: switching was easy - Many

    rendering backends
  15. Strengths: - Designed like MatLab: switching was easy - Many

    rendering backends - Can reproduce just about any plot (with a bit of effort)
  16. 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
  17. None
  18. None
  19. None
  20. 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
  21. Part Two: The Tale of Two API’s

  22. Matplotlib is organized in a hierarchy.

  23. 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.
  24. 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.
  25. 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. ⫶
  26. MATLAB-style Interface Object-Oriented Interface

  27. MATLAB-style Interface Object-Oriented Interface plt.plot(x, y) plt.xlim(-1, 1) plt.title(“My Plot”)

    ...
  28. 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”) ...
  29. 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”) ...
  30. MATLAB-style Interface Object-Oriented Interface plt.gcf() or plt.gca()

  31. Demo Time

  32. None
  33. None