In [38]:
import pandas as pd
%matplotlib inline

Data import and cleanup

In [39]:
ts = pd.read_excel('urbs-result.xlsx', 'Elec.North timeseries', skiprows=[0,2])
In [40]:
to_replace = {
    'Unnamed: 0': 'Time',

    'Level': 'Sto-Level',
    'Stored': 'Sto-In',
    'Retrieved': 'Sto-Out',

    'Mid': 'Imp-Mid',
    'North': 'Imp-North',
    'South': 'Imp-South',
    'Mid.1': 'Exp-Mid',
    'North.1': 'Exp-North',
    'South.1': 'Exp-South'}
ts = ts.rename(columns=to_replace)

Then drop the unneeded columns (storage level, demand, overproduction):

In [41]:
prod = ts.drop(['Sto-Level', 'Demand', 'Overproduction'], axis=1).set_index('Time')
prod['Sto-In'] *= -1

Let the plotting begin

In [42]:
demand = ts.set_index('Time')['Demand']
<matplotlib.axes._subplots.AxesSubplot at 0xdfb9160>

Create a combined production and demand plot; save handle to plot object for later:

In [43]:
fh_prod = prod.plot(kind='area', legend=False)
demand.plot(ax=fh_prod, style='k')
<matplotlib.axes._subplots.AxesSubplot at 0xc4121d0>

Add plot for previously dropped column "storage level" for visual control:

In [44]:
storage = ts.set_index('Time')['Sto-Level']
fh_storage = storage.plot(kind='area', style='r', figsize=(16, 5), ylim=(26e4,None))

Save the plots to files

In [45]:
def save_axes_to_file(fh, filename):
    """Save an axes object to image file."""
    # first retrieve its "parent" figure object
    fig = fh.get_figure()
    # then use its savefig method
    fig.savefig(filename, bbox_inches='tight', dpi=300)
In [46]:
# for each axes (fh_...) object
for fh, name in [(fh_prod, 'Production'), (fh_storage, 'Storage')]:    
    for ext in ['pdf', 'png']:
        filename = "{}.{}".format(name, ext)
        save_axes_to_file(fh, filename)