From 261944cc7ba3aea089c08a0d37017850cc28ec50 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 6 May 2022 15:05:04 -0400 Subject: [PATCH] graphstats: Improve labels on twinx() graphs Signed-off-by: Kevin O'Connor --- scripts/graphstats.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/graphstats.py b/scripts/graphstats.py index f0e24c91..7cd52964 100755 --- a/scripts/graphstats.py +++ b/scripts/graphstats.py @@ -174,7 +174,9 @@ def plot_system(data): color='yellow', alpha=0.3) fontP = matplotlib.font_manager.FontProperties() fontP.set_size('x-small') - ax1.legend(loc='best', prop=fontP) + ax1li, ax1la = ax1.get_legend_handles_labels() + ax2li, ax2la = ax2.get_legend_handles_labels() + ax1.legend(ax1li + ax2li, ax1la + ax2la, loc='best', prop=fontP) ax1.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%H:%M')) ax1.grid(True) return fig @@ -248,7 +250,9 @@ def plot_temperature(data, heaters): ax2.set_ylabel('pwm') fontP = matplotlib.font_manager.FontProperties() fontP.set_size('x-small') - ax1.legend(loc='best', prop=fontP) + ax1li, ax1la = ax1.get_legend_handles_labels() + ax2li, ax2la = ax2.get_legend_handles_labels() + ax1.legend(ax1li + ax2li, ax1la + ax2la, loc='best', prop=fontP) ax1.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%H:%M')) ax1.grid(True) return fig