Last active
November 15, 2017 22:50
-
-
Save erikaris/df0df8013689490d68787d0c277af3b6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# modified from: https://matplotlib.org/gallery/userdemo/demo_gridspec02.html#sphx-glr-gallery-userdemo-demo-gridspec02-py | |
import matplotlib.pyplot as plt | |
from matplotlib.gridspec import GridSpec | |
Y = np.random.normal(loc=0.0, scale=1.0, size=10000) | |
X = np.random.random(size=10000) | |
a = np.array([1,2,3,5,8,13,21,34]) | |
b = np.array([1, 4, 9, 16, 25, 36, 49, 64]) | |
fig = plt.figure() | |
fig.suptitle("GridSpec w/ different subplotpars") | |
gs = GridSpec(4, 3) | |
gs.update(hspace=0.95, wspace= 0.25) | |
ax1 = plt.subplot(gs[0, :]) # shrunken because it only has 1 row (the hspace's effect) | |
# identical to ax1 = plt.subplot(gs.new_subplotspec((0, 0), colspan=3)) | |
ax2 = plt.subplot(gs[1, :-1]) | |
ax3 = plt.subplot(gs[1:, -1]) | |
ax4 = plt.subplot(gs[-1, 0]) | |
ax5 = plt.subplot(gs[-1, -2]) | |
# fill ax2 with scatter plot of X & Y | |
ax2.scatter(X,Y) | |
# fill ax4 with line plot of a & b | |
ax4.plot(a, b) | |
# fill ax5 with histogram of X & Y | |
ax5.hist(X, bins=100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment