Created
September 15, 2017 15:26
-
-
Save p-m-m-c/d8311bc9be4126f38b447b3f3c0c0526 to your computer and use it in GitHub Desktop.
Code for drawing multiple plots on automatically scaled figure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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