plot --output-file
@@ -9,7 +9,6 @@ from matplotlib import pyplot as plt
from .. import database
#TODO: implement --show-* arguments
-#TODO: optionally write result to output file
#TODO: customizable line formats
@@ -153,6 +152,7 @@ class Plotter:
self.ignore_invalid_syntax = args.ignore_invalid_syntax
self.ignore_unknown_frames = args.ignore_unknown_frames
self.ignore_invalid_data = args.ignore_invalid_data
+ self.output_filename = args.output_file
self.signals = Signals(args.signals, args.case_sensitive, args.break_time)
self.x_invalid_syntax = []
@@ -194,6 +194,10 @@ class Plotter:
self.signals.plot()
plt.figlegend()
plt.xlabel(xlabel)
+ if self.output_filename:
+ plt.savefig(self.output_filename)
+ print("result written to %s" % self.output_filename)
+ else:
plt.show()
class Signals:
@@ -338,6 +342,10 @@ def add_subparser(subparsers):
action='store_true',
help='Don\'t print an error message for messages with data which could not be parsed.')
+ decode_parser.add_argument(
+ '-o', '--output-file',
+ help='A file to write the plot to instead of displaying it in a window.')
+
decode_parser.add_argument(
'database',
help='Database file.')
