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)

pull/760/head
Puneet Kohli 7 years ago
parent c9b8bdee18
commit cdd1cb0e8c
  1. 4
      scripts/log_parser/log_parser.py

@ -10,8 +10,8 @@ import os
import platform import platform
import re import re
import sys import sys
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator, FormatStrFormatter from matplotlib.ticker import MultipleLocator, FormatStrFormatter
@ -98,6 +98,8 @@ def log_parser(args):
plt.savefig(save_path, dpi=300) plt.savefig(save_path, dpi=300)
if args.show_plot: if args.show_plot:
plt.show() plt.show()
else:
plt.switch_backend('agg')
if __name__ == "__main__": if __name__ == "__main__":

Loading…
Cancel
Save