From 843a94715dc1cb1be9ff831722b0f5bfb5b445fa Mon Sep 17 00:00:00 2001
From: "Christoph.Knote" <christoph.knote@physik.uni-muenchen.de>
Date: Mon, 18 Dec 2017 15:36:16 +0100
Subject: [PATCH] Finally, some nice plots. Should be it.

---
 boxmox/plotter.py | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/boxmox/plotter.py b/boxmox/plotter.py
index 61916b2..ee01ac5 100644
--- a/boxmox/plotter.py
+++ b/boxmox/plotter.py
@@ -47,8 +47,8 @@ class ExperimentPlotter:
 
     def fluxes(self, spec, fig=None, ax=None,
                plot_legend=True, plot_netflux=True, plot_xaxlabels=True,
-               scale_factor=3600.0 * 1000.0,
-               xlabel='Time in h', ylabel=r'Flux in ppbv h$^{-1}$', plabel=None,
+               scale_factor=3600.0 * 1000.0, ylim=None,
+               xlabel='Time in h', ylabel=r'Flux in ppbv h$^{-1}$', plabel=None, flx_labels = None,
                xaxis=True, yaxis=True):
         '''
         Plot time series of fluxes through a species.
@@ -67,15 +67,20 @@ class ExperimentPlotter:
         netflux = np.zeros(len(times))
 
         for xkey, xvalue in flx.iteritems():
-            ax.plot(times, xvalue * scale_factor, label=xkey)
+            try:
+                ax.plot(times, xvalue * scale_factor, label=flx_labels[xkey]['label'], c=flx_labels[xkey]['color'])
+            except:
+                ax.plot(times, xvalue * scale_factor, label=xkey)
             netflux += np.array(xvalue)
 
         if plot_netflux:
-            ax.plot(times, netflux * scale_factor, label="Net flux", lw=2, c='k')
-        ax.plot(times, np.zeros(len(times)), lw=1, c='gray')
+            ax.plot(times, netflux * scale_factor, label="Net flux", lw=1, c='k')
 
-        ax.grid( alpha=0.5 )
+        ax.grid( alpha=0.5, color='gray', linestyle='solid' )
+        ax.plot(times, np.zeros(len(times)), lw=0.5, alpha=0.5, c='dimgray')
         ax.set( xlim=(times[0],times[-1]), xlabel=xlabel, ylabel=ylabel)
+        if not ylim is None:
+            ax.set( ylim=ylim )
 
         if not plabel is None:
             xmin, xmax = ax.get_xlim()
@@ -84,7 +89,7 @@ class ExperimentPlotter:
                      horizontalalignment='center', verticalalignment='center')
 
         if plot_legend:
-            ax.legend(loc='lower center', fontsize="xx-small", fancybox=True, framealpha=0.5)
+            ax.legend(loc='upper center', fontsize="xx-small", fancybox=True, framealpha=0.75)
 
         if not plot_xaxlabels:
             ax.tick_params(labelbottom='off')
-- 
GitLab