In [1]:
import pandas as pd
import matplotlib.pyplot as plt

import matplotlib
matplotlib.style.use('ggplot')

%matplotlib inline
In [2]:
economics_long = pd.read_csv("./economics_long.csv", index_col=0, parse_dates=["date"])
economics_long.head()

# economics_long.csv link, uncomment to dl directly
# url = r"https://www.dropbox.com/s/rjmzj0vuqj52ztq/economics_long.csv?dl=1"
# economics_long = pd.read_csv(url, index_col=0, parse_dates=["date"])
Out[2]:
date variable value value01
1 1967-07-01 pce 507.4 0.000000
2 1967-08-01 pce 510.5 0.000266
3 1967-09-01 pce 516.3 0.000764
4 1967-10-01 pce 512.9 0.000472
5 1967-11-01 pce 518.1 0.000918

This is just one example using the Axes object(s) returned by pandas.DataFrame.plot()

In [3]:
p = economics_long.pivot('date', 'variable', 'value01').plot(figsize=(12,6), title='Dummy Title', sharey=True)

# set y axis label (can this be done from an argument in DataFrame.plot()?)
p.yaxis.set_label_text('value01 description')
Out[3]:
<matplotlib.text.Text at 0x213233cb2b0>

Here is a function that returns a dict of plot info. You could really go crazy with details but just as a concept for now.

In [4]:
def get_plot_info(p):
    """ in this example p are the Axes objects pd.DataFrame.plot() returns """
    
    plot_info = {
    "title" : p.get_title(),
    "legendlabels": [x.get_text() for x in p.legend_.get_texts()],
    "x_label": p.xaxis.get_label_text(),
    "x_ticks": [x.get_text() for x in p.xaxis.get_majorticklabels()],
    "y_label": p.yaxis.get_label_text(),
    "y_ticks": [x.get_text() for x in p.yaxis.get_majorticklabels()]
    }
    
    return plot_info
In [5]:
get_plot_info(p)
Out[5]:
{'legendlabels': ['pce', 'pop', 'psavert', 'uempmed', 'unemploy'],
 'title': 'Dummy Title',
 'x_label': 'date',
 'x_ticks': ['1969',
  '1974',
  '1979',
  '1984',
  '1989',
  '1994',
  '1999',
  '2004',
  '2009',
  '2014'],
 'y_label': 'value01 description',
 'y_ticks': ['0.0', '0.2', '0.4', '0.6', '0.8', '1.0']}