From 7db6fa7bfcc52afbdff27caa83ade3ddd65026f2 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sat, 30 Dec 2017 18:20:53 -0500 Subject: [PATCH] graphstats: Fix case where an Xwindows display may not be available Matplotlib will try to open a display by default - tell it not to do that so that it can run in batch mode on headless machines. Signed-off-by: Kevin O'Connor --- scripts/graphstats.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/graphstats.py b/scripts/graphstats.py index d037983a..4c656c7a 100755 --- a/scripts/graphstats.py +++ b/scripts/graphstats.py @@ -5,7 +5,9 @@ # # This file may be distributed under the terms of the GNU GPLv3 license. import optparse, datetime -import matplotlib.pyplot as plt, matplotlib.dates as mdates +import matplotlib +matplotlib.use('Agg') +import matplotlib.pyplot, matplotlib.dates MAXBANDWIDTH=25000. MAXBUFFER=2. @@ -89,7 +91,7 @@ def plot_mcu(data, maxbw, outname, graph_awake=False): lastbw = bw # Build plot - fig, ax1 = plt.subplots() + fig, ax1 = matplotlib.pyplot.subplots() ax1.set_title("MCU bandwidth and load utilization") ax1.set_xlabel('Time') ax1.set_ylabel('Usage (%)') @@ -99,10 +101,9 @@ def plot_mcu(data, maxbw, outname, graph_awake=False): ax1.plot_date(times, loads, 'r', label='MCU load') ax1.plot_date(times, hostbuffers, 'c', label='Host buffer') ax1.legend(loc='best') - ax1.xaxis.set_major_formatter(mdates.DateFormatter('%H:%M')) - #plt.gcf().autofmt_xdate() + ax1.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%H:%M')) ax1.grid(True) - plt.savefig(outname) + fig.savefig(outname) def main(): usage = "%prog [options] "