@@ -411,11 +411,12 @@ def get_data(self, msg):
411
411
412
412
413
413
class BagTopicPlotter :
414
- def __init__ (self , bags , topics , plot_arrays = True , plot_headers = True , plot_format = 'png' , bag_time = False ):
414
+ def __init__ (self , bags , topics , plot_arrays = True , plot_headers = True , plot_format = 'png' , plot_style = '.-' , bag_time = False ):
415
415
self ._bags = bags
416
416
self ._plot_arrays = plot_arrays
417
417
self ._plot_headers = plot_headers
418
418
self ._plot_format = plot_format
419
+ self ._plot_style = plot_style
419
420
self ._bag_time = bag_time
420
421
421
422
self ._bag_topic_helpers = {}
@@ -507,15 +508,15 @@ def __init__(self, bags, topics, plot_arrays=True, plot_headers=True, plot_forma
507
508
ax .set_color_cycle ([plt .cm .rainbow (i ) for i in numpy .linspace (0 , 1 , len (values ))])
508
509
509
510
for topic in plottable_topics :
510
- plt .plot (times [topic ], values [topic ])
511
+ plt .plot (times [topic ], values [topic ], self . _plot_style )
511
512
512
513
plt .legend (plottable_topics , loc = 0 )
513
514
514
515
plt .savefig (bag .replace ('.bag' , '' ) + '.' + self ._plot_format )
515
516
516
517
plt .close (fig )
517
518
except OverflowError as e :
518
- rospy .logerr ('%s: Failed to save plot as %s image file (try other format, e.g. svg): %s' , filename , self ._plot_format , e .message )
519
+ rospy .logerr ('Failed to save plot as %s image file (try other format, e.g. svg): %s' , self ._plot_format , e .message )
519
520
520
521
def get_plot_fields (self , topic_name ):
521
522
"""
@@ -614,12 +615,13 @@ def get_plot_fields(self, topic_name):
614
615
parser .add_argument ('--noarr' , help = 'do not plot array fields' , action = 'store_true' )
615
616
parser .add_argument ('--nohdr' , help = 'do not plot header fields' , action = 'store_true' )
616
617
parser .add_argument ('--plot_format' , help = 'output plot format' , default = 'png' )
618
+ parser .add_argument ('--plot_style' , help = 'output plot style' , default = '.-' )
617
619
parser .add_argument ('--bag_time' , help = 'use bag time instead of msg header time' , action = 'store_true' )
618
620
619
621
args = parser .parse_args ()
620
622
621
623
try :
622
- BagTopicPlotter (args .bags , args .topics , not args .noarr , not args .nohdr , args .plot_format , args .bag_time )
624
+ BagTopicPlotter (args .bags , args .topics , not args .noarr , not args .nohdr , args .plot_format , args .plot_style , args . bag_time )
623
625
except Exception , e :
624
626
import traceback
625
627
traceback .print_exc ()
0 commit comments