diff --git a/rqt_plot/src/rqt_plot/data_plot/__init__.py b/rqt_plot/src/rqt_plot/data_plot/__init__.py index 8d88d54f..46f918ae 100644 --- a/rqt_plot/src/rqt_plot/data_plot/__init__.py +++ b/rqt_plot/src/rqt_plot/data_plot/__init__.py @@ -335,7 +335,7 @@ 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 @@ -343,14 +343,19 @@ def update_values(self, curve_id, values_x, values_y): 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