From 0e06cf43ad321e61611628646dd38c0401906e07 Mon Sep 17 00:00:00 2001
From: Junjie Zhang <junjie.zhang@eonerc.rwth-aachen.de>
Date: Mon, 7 Oct 2019 12:12:05 +0200
Subject: [PATCH] update plottool and timeseries

---
 villas/dataprocessing/plottools.py  | 4 ++--
 villas/dataprocessing/timeseries.py | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/villas/dataprocessing/plottools.py b/villas/dataprocessing/plottools.py
index 06d46fe..b8b7d37 100644
--- a/villas/dataprocessing/plottools.py
+++ b/villas/dataprocessing/plottools.py
@@ -4,7 +4,7 @@ from .timeseries import *
 import scipy.signal as signal
 
 
-def plot_timeseries(figure_id, timeseries, marker='None', plt_linestyle='-', plt_linewidth=2, plt_color=None, plt_legend_loc='lower right', plt_legend=True, inlineLabel = False):
+def plot_timeseries(figure_id, timeseries, marker='None', plt_linestyle='-', plt_linewidth=2, plt_color=None, plt_legend_loc='lower right', plt_legend=True, inlineLabel = False, inlinLabelPos=[-1,-1]):
     """
     This function plots either a single timeseries or several timeseries in the figure defined by figure_id.
     Several timeseries (handed over in a list) are plotted in several subplots.
@@ -30,7 +30,7 @@ def plot_timeseries(figure_id, timeseries, marker='None', plt_linestyle='-', plt
             if(plt_legend):
                 plt.legend()
     if(inlineLabel):
-        plt.text(timeseries.time[-1], timeseries.values[-1], timeseries.label)
+        plt.text(timeseries.time[inlinLabelPos[0]], timeseries.values[inlinLabelPos[1]], timeseries.label)
 
 
 def set_timeseries_labels(timeseries, timeseries_labels):
diff --git a/villas/dataprocessing/timeseries.py b/villas/dataprocessing/timeseries.py
index c47fd71..c1180fa 100644
--- a/villas/dataprocessing/timeseries.py
+++ b/villas/dataprocessing/timeseries.py
@@ -223,7 +223,9 @@ class TimeSeries:
     
     @staticmethod
     def rel_diff(name, ts1, ts2):
-        """Returns relative difference between two time series objects to the first.
+        """
+        Returns relative difference between two time series objects to the first.
+        calculated against the max of ts1.
         """
         diff_val=TimeSeries.diff('diff', ts1, ts2).values
         # relative error to the max value of ts1
-- 
GitLab