Skip to content

Instantly share code, notes, and snippets.

@pozitron57
Created October 17, 2016 20:09
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 pozitron57/6524c0e18f3c8779ebe1b9b99e3b16d7 to your computer and use it in GitHub Desktop.
Save pozitron57/6524c0e18f3c8779ebe1b9b99e3b16d7 to your computer and use it in GitHub Desktop.
gridspec in python matplotlib
#! /usr/bin/env python
#coding=utf8
from pylab import *
from matplotlib import *
gs = gridspec.GridSpec(2, 1) #subplots ratio
f, (ax1, ax2) = plt.subplots(2, sharex=True)
ax1 = plt.subplot(gs[0, 0])
ax2 = plt.subplot(gs[1, 0])
## Sample plot
x1=np.linspace(0,10)
y1=np.linspace(0,10)
x2=np.linspace(0,10)
y2=np.linspace(0,10)
ax1.plot(x1,y1)
ax2.plot(x2,y2**3)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment