From 3e33f3997aaf485d42c2553ea39da375516e3bc8 Mon Sep 17 00:00:00 2001 From: Nikhar Abbas Date: Mon, 28 Sep 2020 14:22:00 -0600 Subject: [PATCH] Clean up plotting function --- ROSCO_toolbox/utilities.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ROSCO_toolbox/utilities.py b/ROSCO_toolbox/utilities.py index 96f124e48..2ba1a30ea 100644 --- a/ROSCO_toolbox/utilities.py +++ b/ROSCO_toolbox/utilities.py @@ -71,10 +71,9 @@ def plot_fast_out(self, cases, fast_dict, showplot=False, fignum=None, xlim=None # channels to plot channels = cases[case] # instantiate plot and legend - fig, axes = plt.subplots(len(channels), 1, sharex=True, num=fignum) - + fig, axes = plt.subplots(len(channels), 1, sharex=True, num=fignum, constrained_layout=True) myleg = [] - for fast_out in fast_dict: + for fast_out in fast_dict: # Multiple channels # write legend Time = fast_out['Time'] myleg.append(fast_out['meta']['name']) @@ -85,19 +84,20 @@ def plot_fast_out(self, cases, fast_dict, showplot=False, fignum=None, xlim=None axj.plot(Time, fast_out[channel]) # label unit_idx = fast_out['meta']['channels'].index(channel) - axj.set(ylabel='{:^} \n ({:^})'.format( + axj.set_ylabel('{:^} \n ({:^})'.format( channel, fast_out['meta']['attribute_units'][unit_idx])) axj.grid(True) except: print('{} is not available as an output channel.'.format(channel)) axes[0].set_title(case) - else: # Single channel + + else: # Single channel try: # plot axes.plot(Time, fast_out[channel]) # label - axes.set(ylabel='{:^} \n ({:^})'.format( + axes.set_ylabel('{:^} \n ({:^})'.format( channel, fast_out['meta']['attribute_units'][unit_idx])) axes.grid(True)