From a3950e4dce79889fd4b514ec4c226d137ff4acb5 Mon Sep 17 00:00:00 2001 From: Kevin Kuns <kevin.kuns@ligo.org> Date: Tue, 16 Mar 2021 00:19:17 -0400 Subject: [PATCH] fix plot styles * fix bug where default styles don't check if a property has been defined with an alias (e.g. lw instead of linewidth) * make minor grid more transparent --- gwinc/plot.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/gwinc/plot.py b/gwinc/plot.py index 8527c856..dc8d8a9a 100644 --- a/gwinc/plot.py +++ b/gwinc/plot.py @@ -19,12 +19,16 @@ def plot_trace( total = trace.asd ylim = [min(total)/10, max(total)] - style = dict( - color='#000000', - alpha=0.6, - linewidth=4, - ) + + style = dict(alpha=0.6) + style.update(getattr(trace, 'style', {})) + if 'color' not in style and 'c' not in style: + style['color'] = '#000000' + if 'alpha' not in style: + style['alpha'] = 0.6 + if 'linewidth' not in style and 'lw' not in style: + style['linewidth'] = 4 if 'label' in style: style['label'] = 'Total ' + style['label'] else: @@ -35,18 +39,26 @@ def plot_trace( style = strace.style if 'label' not in style: style['label'] = name - elif 'linewidth' not in style: + if 'linewidth' not in style and 'lw' not in style: style['linewidth'] = 3 ax.loglog(trace.freq, strace.asd, **style) ax.grid( True, - which='both', + which='major', linewidth=0.5, ls='-', alpha=0.5, ) + ax.grid( + True, + which='minor', + linewidth=0.5, + ls='-', + alpha=0.2, + ) + ax.legend( ncol=2, fontsize='small', -- GitLab