Created
March 23, 2014 04:57
-
-
Save sinhrks/9719021 to your computer and use it in GitHub Desktop.
Pandas dataframe with centered bar
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 string | |
from pandas import DataFrame, Series | |
from numpy.random import randn | |
import matplotlib.pyplot as plt | |
df = DataFrame(randn(7, 4), | |
index=list(string.ascii_letters[:7]), | |
columns=['x', 'y', 'z', 'four']) | |
series = Series(randn(7), index=range(7)) | |
fig, axes = plt.subplots(1, 4, figsize=(14, 3)) | |
plt.subplots_adjust(top=0.9, bottom=0.1, left=0.05, right=0.95, hspace=0.35) | |
df.plot(kind='bar', title='Default(center)', ax=axes[0], legend=False) | |
series.plot(ax=axes[0]) | |
df.plot(kind='bar', stacked=True, title='Default(center)', ax=axes[1], legend=False) | |
series.plot(ax=axes[1]) | |
df.plot(kind='bar', title='Align=edge', ax=axes[2], legend=False, align='edge') | |
series.plot(ax=axes[2]) | |
df.plot(kind='bar', stacked=True, title='Align=edge', ax=axes[3], legend=False, align='edge') | |
series.plot(ax=axes[3]) | |
plt.show() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example for
pandas-dev/pandas#6691