Chapter 3 Plotting with Python

From [xkcd](

Figure 3.1: From xkcd.

Plots used in science have a specific look and feel. For instance, you will never see a graph produced using the default setting in Excel. Python can produce phenomenal plots that are of publication quality. In this session, we will learn how to use Python’s main plotting package matplotlib to generate scientific plots.

Before proceeding it is important to understand the various parts of a plot produced by matplotlib. In particular you should understand what an axes is. Please refer to Figure 3.2 to see the various parts of a plot produced by matplotlib.

Anatomy of a `matplotlib` plot.

Figure 3.2: Anatomy of a matplotlib plot.

Plotting data is an essential tool for a scientist. It would be best if you had two types of plotting tools. One for making quick exploratory plots and another for making finalised explanatory plots for reports/publication. matplotlib can easily fullfil both these needs.