Skip to content

Commit

Permalink
Clean up plotting function
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhar-abbas committed Sep 28, 2020
1 parent ac48684 commit 3e33f39
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ROSCO_toolbox/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand All @@ -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)
Expand Down

0 comments on commit 3e33f39

Please sign in to comment.