Skip to content

Instantly share code, notes, and snippets.

@p-m-m-c
Created September 15, 2017 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save p-m-m-c/d8311bc9be4126f38b447b3f3c0c0526 to your computer and use it in GitHub Desktop.
Save p-m-m-c/d8311bc9be4126f38b447b3f3c0c0526 to your computer and use it in GitHub Desktop.
Code for drawing multiple plots on automatically scaled figure
# Code for plotting multiple plots
n_subplots = 8
assert n_subplots%2 == 0, 'Use even number of subplots'
fig, axarr = plt.subplots(n_subplots//2,2)
fig.set_figwidth(15)
fig.set_figheight(4*axarr.shape[0])
for numb, ax in enumerate(axarr.ravel()):
X = np.arange(10)
y = [x+5 for x in X]
z = [x**2 for x in X]
ax.plot(X,y)
ax.plot(X,z)
ax.set_title("Plot number {}".format(numb))
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment