Skip to content

Commit

Permalink
rqt_plot: add keyword arg to make sort optional
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-thomas committed Sep 9, 2016
1 parent 2cbfb7d commit 417fd3f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions rqt_plot/src/rqt_plot/data_plot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,22 +335,27 @@ def remove_curve(self, curve_id):
if self._data_plot_widget:
self._data_plot_widget.remove_curve(curve_id)

def update_values(self, curve_id, values_x, values_y):
def update_values(self, curve_id, values_x, values_y, sort_data=True):
"""Append new data to an existing curve
`values_x` and `values_y` will be appended to the existing data for
`curve_id`
Note that the plot is not redraw automatically; call `redraw()` to make
any changes visible to the user.
If `sort_data` is set to False, values won't be sorted by `values_x`
order.
"""
curve = self._get_curve(curve_id)
curve['x'] = numpy.append(curve['x'], values_x)
curve['y'] = numpy.append(curve['y'], values_y)
# sort resulting data, so we can slice it later
sort_order = curve['x'].argsort()
curve['x'] = curve['x'][sort_order]
curve['y'] = curve['y'][sort_order]

if sort_data:
# sort resulting data, so we can slice it later
sort_order = curve['x'].argsort()
curve['x'] = curve['x'][sort_order]
curve['y'] = curve['y'][sort_order]

def clear_values(self, curve_id=None):
"""Clear the values for the specified curve, or all curves
Expand Down

0 comments on commit 417fd3f

Please sign in to comment.