plottools.py 833 Bytes
Newer Older
1
import matplotlib.pyplot as plt
2
import numpy as np
3
from .timeseries import *
4
5


6
def plot_timeseries(figure_id, timeseries, plt_linestyle='-'):
7
8
    plt.figure(figure_id)

9
10
    if not isinstance(timeseries, list):
        plt.plot(timeseries.time, timeseries.values, linestyle=plt_linestyle, label=timeseries.label)
11
        plt.gca().autoscale(axis='x', tight=True)
Markus Mirz's avatar
udpate    
Markus Mirz committed
12
        plt.legend(loc='lower right')
13
14
15
16
17
18
    else:
        for ts in timeseries:
            plt.subplot(len(timeseries), 1, timeseries.index(ts) + 1)
            plt.plot(ts.time, ts.values, linestyle=plt_linestyle, label=ts.label)
            plt.gca().autoscale(axis='x', tight=True)
            plt.legend()
19

20
21
22
def set_time_series_labels(timeseries_list, time_series_labels):
    for ts in timeseries_list:
        ts.label = time_series_labels[timeseries_list.index(ts)]