Skip to content

Commit 7b006dd

Browse files
author
Enrique Fernandez
committed
Add --plot_style arg
1 parent 4212779 commit 7b006dd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

bag_tools/scripts/plot.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,12 @@ def get_data(self, msg):
411411

412412

413413
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):
415415
self._bags = bags
416416
self._plot_arrays = plot_arrays
417417
self._plot_headers = plot_headers
418418
self._plot_format = plot_format
419+
self._plot_style = plot_style
419420
self._bag_time = bag_time
420421

421422
self._bag_topic_helpers = {}
@@ -507,7 +508,7 @@ def __init__(self, bags, topics, plot_arrays=True, plot_headers=True, plot_forma
507508
ax.set_color_cycle([plt.cm.rainbow(i) for i in numpy.linspace(0, 1, len(values))])
508509

509510
for topic in plottable_topics:
510-
plt.plot(times[topic], values[topic])
511+
plt.plot(times[topic], values[topic], self._plot_style)
511512

512513
plt.legend(plottable_topics, loc=0)
513514

@@ -614,12 +615,13 @@ def get_plot_fields(self, topic_name):
614615
parser.add_argument('--noarr', help='do not plot array fields', action='store_true')
615616
parser.add_argument('--nohdr', help='do not plot header fields', action='store_true')
616617
parser.add_argument('--plot_format', help='output plot format', default='png')
618+
parser.add_argument('--plot_style', help='output plot style', default='.-')
617619
parser.add_argument('--bag_time', help='use bag time instead of msg header time', action='store_true')
618620

619621
args = parser.parse_args()
620622

621623
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)
623625
except Exception, e:
624626
import traceback
625627
traceback.print_exc()

0 commit comments

Comments
 (0)