Skip to content

Instantly share code, notes, and snippets.

@bdjackson
Created December 16, 2014 14:22
Show Gist options
  • Save bdjackson/3f9f61b8c32bd2f13a72 to your computer and use it in GitHub Desktop.
Save bdjackson/3f9f61b8c32bd2f13a72 to your computer and use it in GitHub Desktop.
import numpy
import pandas
# fill a random dataframe
# Example taken from:
# http://pandas.pydata.org/pandas-docs/version/0.15.0/visualization.html
ts = pandas.Series(numpy.random.randn(1000),
index=pandas.date_range('1/1/2000',
periods=1000))
ts = ts.cumsum()
df = pandas.DataFrame(numpy.random.randn(1000, 4),
index=ts.index,
columns=list('ABCD'))
df = df.cumsum()
# plot the data frame, and get the figure from the axes
ax = df.plot()
fig = ax.get_figure()
# save the figure
fig.savefig('my_plot.png',bbox_inches='tight',dpi=300)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment