Matplotlib Cheat Sheet Guide
Matplotlib Cheat Sheet Guide
plot([X], Y, [fmt], …) API ax.set_[xy]scale(scale, …) from matplotlib import ticker import [Link] as mpla
ax.[xy]axis.set_[minor|major]_locator(locator)
Cheat sheet Version 3.7.4 X, Y, fmt, color, marker, linestyle linear log
any values values > 0 T = [Link](0, 2*[Link], 100)
S = [Link](T)
Quick start API scatter(X, Y, …) API symlog logit line, = [Link](T, S)
X, Y, [s]izes, [c]olors, marker, cmap any values 0 < values < 1 def animate(i):
import numpy as np line.set_ydata([Link](T+i/50))
import matplotlib as mpl anim = [Link](
import [Link] as plt bar[h](x, height, …) API
x, height, width, bottom, align, color
Projections API [Link](), animate, interval=5)
[Link]()
subplot(…, projection=p)
X = [Link](0, 2*[Link], 100) p=’polar’ p=’3d’ API
Y = [Link](X) imshow(Z, …) API Styles API
Z, cmap, interpolation, extent, origin
fig, ax = [Link]() [Link](style)
[Link](X, Y, color=’green’) contour[f]([X], [Y], Z, …) API p=[Link]() API
X, Y, Z, levels, colors, extent, origin import [Link] as ccrs
[Link](“[Link]”) Tick formatters API
[Link]()
pcolormesh([X], [Y], Z, …) API from matplotlib import ticker
ax.[xy]axis.set_[minor|major]_formatter(formatter)
Anatomy of a figure X, Y, Z, vmin, vmax, cmap
Lines API
pie(X, …) API
Z, explode, labels, colors, radius
Quick reminder
Markers API
text(x, y, text, …) API [Link]()
x, y, text, va, ha, size, weight, transform ax.set_[xy]lim(vmin, vmax)
ax.set_[xy]label(label)
ax.set_[xy]ticks(ticks, [labels])
fill[_between][x](…) API ax.set_[xy]ticklabels(labels)
X, Y1, Y2, color, where Ornaments ax.set_title(title)
ax.tick_params(width=10, …)
[Link](…) API ax.set_axis_[on|off]()
handles, labels, loc, title, frameon
Advanced plots [Link](title)
title
fig.tight_layout()
step(X, Y, [fmt], …) API
Colors API
Legend label [Link](), [Link]()
X, Y, fmt, color, marker, where handletextpad handle
handlelength
markerfacecolor (mfc)
[Link](’axes’, linewidth=1, …)
’Cn’ Label 1 Label 3 [fig|ax].patch.set_alpha(0)
Subplots layout API ’x’ labelspacing
text=r’$\frac{-e^{i\pi}}{2^n}$’
boxplot(X, …) API
markeredgecolor (mec)
terrain
ocean
cubehelix
rainbow
twilight