Matplotlib Cheatsheet

kuniga.me > Docs > Matplotlib Cheatsheet

Matplotlib Cheatsheet

Syntax for common tasks I run into often. Assumes Python 3.

Index

  1. Templates
    1. Single plot
    2. Multiple Plots
  2. Properties
    1. Dimensions
    2. Title

Templates

Single plot

fig, ax =  plt.subplots(figsize=(18, 5))

Multiple Plots

One row, two columns:

fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(18, 5))

Properties

Dimensions

Do on creation, via figsize:

fig, ax =  plt.subplots(figsize=(18, 5))

Width 18 and height 5 are assumed to be inches.

Title

ax.set_title('My title')