From cdd1cb0e8c4fda3671714bb5ad6ba1825cff16d1 Mon Sep 17 00:00:00 2001 From: Puneet Kohli Date: Sun, 6 May 2018 16:45:26 -0500 Subject: [PATCH] Change matplotlib backend to 'agg' when 'show_plot' is false. This allows the script to be run from command line without any errors (for ex, on a remote machine) --- scripts/log_parser/log_parser.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/log_parser/log_parser.py b/scripts/log_parser/log_parser.py index 2804c02a..631e5497 100644 --- a/scripts/log_parser/log_parser.py +++ b/scripts/log_parser/log_parser.py @@ -10,8 +10,8 @@ import os import platform import re import sys - import matplotlib.pyplot as plt + from matplotlib.ticker import MultipleLocator, FormatStrFormatter @@ -98,6 +98,8 @@ def log_parser(args): plt.savefig(save_path, dpi=300) if args.show_plot: plt.show() + else: + plt.switch_backend('agg') if __name__ == "__main__":