Created
December 8, 2016 15:26
-
-
Save jmarrec/17df8922d268d63f32259f4bbe36ccfa to your computer and use it in GitHub Desktop.
Plot pandas df onto gridpsec
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
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