Skip to content

Latest commit

 

History

History
66 lines (49 loc) · 1002 Bytes

File metadata and controls

66 lines (49 loc) · 1002 Bytes

PYTHON python::matplotlib

1. brief

simple example
import matplotlib as plt
import numpy as np

x = np.arange(10)
y = np.sin(x)

plt.plot(y)
plt.scatter(x, y)
plt.show()

2. arrangement

regular grid
import matplotlib as plt
fig, axes = plt.subplots(5, 3)
irregular grid
import matplotlib.pyplot as plt
from matplotlib import gridspec
#
fig = plt.figure(figsize=(8, 6))
# make a grid 4 rows, 3 cols
grid = gridspec.GridSpec(4, 3)
# first axe takes 3 rows, 3 cols
ax1 = fig.add_subplot(grid[0:3, :])
# second axe takes bottom left corner
ax2 = fig.add_subplot(grid[3, 0])
# some plots
ax1.plot([x*x for x in range(1, 100)])
ax2.plot([1./x for x in range(1, 100)])
plt.show()

3. decorations

4. animation

plt.sleep(0.1)  # let the opportunity to draw