Skip to content

Commit

Permalink
rqt_plot: changed mat_data_plot autoscaling to maybe prevent #48
Browse files Browse the repository at this point in the history
  • Loading branch information
DorianScholz committed Dec 17, 2012
1 parent 1543049 commit 073e228
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions rqt_plot/src/rqt_plot/mat_data_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,29 +126,29 @@ def redraw(self):
xmax = 0
for curve in self._curves.values():
data_x, data_y, plot = curve
data_x = numpy.array(data_x)
data_y = numpy.array(data_y)
if len(data_x) == 0:
continue

xmax = max(xmax, data_x[-1])
self._canvas.axes.set_xbound(lower=xmax - 5, upper=xmax)

if ymin is None:
ymin = min(data_y)
ymax = max(data_y)
ymin = min(data_y[-100:])
ymax = max(data_y[-100:])
else:
ymin = min(min(data_y), ymin)
ymax = max(max(data_y), ymax)
ymin = min(min(data_y[-100:]), ymin)
ymax = max(max(data_y[-100:]), ymax)

# pad the min/max
delta = max(ymax - ymin, 0.1)
ymin -= .05 * delta
ymax += .05 * delta

self._canvas.axes.set_ybound(lower=ymin, upper=ymax)
plot.set_data(data_x, data_y)

# Set plot data on current axes
for curve in self._curves.values():
data_x, data_y, plot = curve
plot.set_data(numpy.array(data_x), numpy.array(data_y))
if ymin is not None:
self._canvas.axes.set_xbound(lower=xmax - 5, upper=xmax)
self._canvas.axes.set_ybound(lower=ymin, upper=ymax)

self._canvas.draw()

0 comments on commit 073e228

Please sign in to comment.