Skip to content

Instantly share code, notes, and snippets.

@jmarrec
Created December 8, 2016 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 jmarrec/17df8922d268d63f32259f4bbe36ccfa to your computer and use it in GitHub Desktop.
Save jmarrec/17df8922d268d63f32259f4bbe36ccfa to your computer and use it in GitHub Desktop.
Plot pandas df onto gridpsec
import pandas as pd
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
df = pd.DataFrame(np.random.rand(100,2), columns=['A','B'])
gs = mpl.gridspec.GridSpec(nrows=2, ncols=1)
for i, col in enumerate(df):
ax = plt.subplot(gs[i])
df[col].plot(ax=ax)
# Note: I can create exactly the same stuff with this one-liner
df.plot(subplots=True, layout=(2,1), sharex=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment