kuniga.me > Docs > Matplotlib Cheatsheet
Syntax for common tasks I run into often. Assumes Python 3.
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(18, 5))
One row, two columns:
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(18, 5))
ax.plot(xs, ys)
ax.plot(x, color='red')
Do on creation, via figsize
:
fig, ax = plt.subplots(figsize=(18, 5))
Width 18 and height 5 are assumed to be inches.
ax.set_title('My title')