diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2021-08-23 21:04:25 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2021-08-24 10:19:23 -0400 |
commit | d759b4e532d203e511bdb68021180039cffd9df3 (patch) | |
tree | 44a6a92522f1cebd16dcd59cf604ae6dbc2a0110 /scripts | |
parent | 7aa2c11b3aca649962840dde4155cbc7b9789473 (diff) | |
download | kutter-d759b4e532d203e511bdb68021180039cffd9df3.tar.gz kutter-d759b4e532d203e511bdb68021180039cffd9df3.tar.xz kutter-d759b4e532d203e511bdb68021180039cffd9df3.zip |
motan_graph: Fix legend when using matplotlib twinx
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/motan/motan_graph.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/scripts/motan/motan_graph.py b/scripts/motan/motan_graph.py index b593c1ce..9826f1a2 100755 --- a/scripts/motan/motan_graph.py +++ b/scripts/motan/motan_graph.py @@ -53,8 +53,13 @@ def plot_motion(amanager, graphs): pparams = {'label': label['label'], 'alpha': 0.8} pparams.update(plot_params) ax.plot(times, datasets[dataset], **pparams) - ax.legend(loc='best', prop=fontP) - ax.grid(True) + if twin_ax is not None: + li1, la1 = graph_ax.get_legend_handles_labels() + li2, la2 = twin_ax.get_legend_handles_labels() + twin_ax.legend(li1 + li2, la1 + la2, loc='best', prop=fontP) + else: + graph_ax.legend(loc='best', prop=fontP) + graph_ax.grid(True) rows[-1].set_xlabel('Time (s)') return fig |