From 8500d524d450d8a7f079a4970c7d8d3def3b8265 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 2 Feb 2024 18:35:49 +1100 Subject: [PATCH] grapher: allow show_flightmode = 0,1,2 better for publication to separate the mode legend --- MAVProxy/modules/lib/grapher.py | 6 +++--- MAVProxy/tools/MAVExplorer.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MAVProxy/modules/lib/grapher.py b/MAVProxy/modules/lib/grapher.py index ffd6f43068..83cdc89408 100755 --- a/MAVProxy/modules/lib/grapher.py +++ b/MAVProxy/modules/lib/grapher.py @@ -381,7 +381,7 @@ def plotit(self, x, y, fields, colors=[], title=None, interactive=True): if self.grid: pylab.grid() - if self.show_flightmode: + if self.show_flightmode != 0: alpha = 0.3 xlim = self.ax1.get_xlim() for i in range(len(self.flightmode_list)): @@ -409,14 +409,14 @@ def plotit(self, x, y, fields, colors=[], title=None, interactive=True): else: self.fig.canvas.set_window_title(title) - if self.show_flightmode: + if self.show_flightmode != 0: mode_patches = [] for mode in self.modes_plotted.keys(): (color, alpha) = self.modes_plotted[mode] mode_patches.append(matplotlib.patches.Patch(color=color, label=mode, alpha=alpha*1.5)) labels = [patch.get_label() for patch in mode_patches] - if ax1_labels != []: + if ax1_labels != [] and self.show_flightmode != 2: patches_legend = matplotlib.pyplot.legend(mode_patches, labels, loc=self.legend_flightmode) self.fig.gca().add_artist(patches_legend) else: diff --git a/MAVProxy/tools/MAVExplorer.py b/MAVProxy/tools/MAVExplorer.py index 4ed4e71f4d..5d9db27bb5 100755 --- a/MAVProxy/tools/MAVExplorer.py +++ b/MAVProxy/tools/MAVExplorer.py @@ -105,7 +105,7 @@ def __init__(self): MPSetting('condition', str, None, 'condition'), MPSetting('xaxis', str, None, 'xaxis'), MPSetting('linestyle', str, None, 'linestyle'), - MPSetting('show_flightmode', bool, True, 'show flightmode'), + MPSetting('show_flightmode', int, 1, 'show flightmode'), MPSetting('sync_xzoom', bool, True, 'sync X-axis zoom'), MPSetting('sync_xmap', bool, True, 'sync X-axis zoom for map'), MPSetting('legend', str, 'upper left', 'legend position'),