Contribute Media
A thank you to everyone who has made this possible: Read More

Matplotlib

Description

This tutorial is for Python users who would like to create nice 2d plots with Python.

Audience Level

Students should have a working knowledge of Python. NumPy knowledge is helpful but not required.

Prerequisites

Please bring your laptop with the operating system of your choice (Linux, Mac OS X, Windows). In addition to Python 3.6 (2.7 works if really want to use it), we need:

If you use Anaconda you should have all requirements installed. If you use a new conda environment install with:

conda install jupyter numpy matplotlib

The same goes for pip:

pip install jupyter numpy matplotlib

Method

This is a hands-on course. Students are strongly encouraged to work along with the trainer at the interactive prompt. There will be exercises the students need to do on their own. Experience shows that this active involvement is essential for an effective learning.

Content
The library matplotlib provides many different types of diagrams from within Python with only few lines of code. Examples are used to exercise the use of this library. The tutorial provides an overview how to create plots . Using matplotlib from Jupyter Notebook provides an interactive environment for fast testing of ideas. We will be using this for most of the tutorial.
With a simple plot we learn how to add axis labels, titles and a legend. The GUI offers zooming, panning, changing of plot sizes and other interactive ways to modify the plot. We will use Python to change properties of existing plots such as line colors, marker symbols, or line styles. There are several ways how to place text on plots. You will learn about the different coordinate systems relative to the plot, the canvas or the figure. Another topic are ticks, where to put them and how to format them to achieve publication-quality plots. The concepts of figures, subplots, and axes and how they relate to each other will be explained with examples.
Matplotlib offers many different types of plots. The tutorial introduces several of them with an example. A more advanced topic will be creating your own plot types. Finally, we will create a small animation to explore the possibilities to visualize changes.
Outline
  • Introduction
  • Jupyter
  • Simple plots
  • Properties
  • Text
  • Ticks
  • Figures, subplots, and axes
  • Other types of plots
  • The class library
  • Creating New Plot Types
  • Animations
Audience level: Novice

Details

Improve this page