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


6
7
8
9
10
11
def plot_single_ts(figure_id, time_series, plt_linestyle='-'):
    plt.figure(figure_id)
    plt.plot(time_series.time, time_series.values, linestyle=plt_linestyle, label=time_series.label)
    plt.gca().autoscale(axis='x', tight=True)
    plt.legend()

12
13
14
15
16
17
18
def plot_in_subplots(figure_id, time_series, plt_linestyle='-'):
    plt.figure(figure_id)
    for ts in time_series:
        plt.subplot(len(time_series), 1, time_series.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
23
24
25
26
27
def plot_in_oneplot(figure_id, time_series, plt_linestyle='-'):
    plt.figure(figure_id)
    for ts in time_series:
        plt.subplot(len(time_series), 1, time_series.index(ts) + 1)
        plt.plot(ts.time, ts.values, linestyle=plt_linestyle, label=ts.label)
        plt.gca().autoscale(axis='x', tight=True)
        plt.legend()

28

29
30
31
def set_time_series_labels(time_series, time_series_labels):
    for ts in time_series:
        ts.label = time_series_labels[time_series.index(ts)]