Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 import operator
00011 import numpy
00012
00013
00014 from rqt_plot.data_plot import DataPlot
00015
00016
00017
00018
00019
00020 class FullSizeDataPlot(DataPlot):
00021 def __init__(self, parent=None):
00022 super(FullSizeDataPlot, self).__init__(parent)
00023 self.max_range = 180
00024 self.min_range = 0
00025 self.dynamic_range = False
00026 self._ymin = 0
00027 self._ymax = 0
00028
00029 def reset(self):
00030 self._ymin = 0
00031 self._ymax = 0
00032
00033
00034
00035
00036 def _update_legend(self):
00037 handles, labels = self._canvas.axes.get_legend_handles_labels()
00038 if handles:
00039 hl = sorted(zip(handles, labels), key=operator.itemgetter(1))
00040 handles, labels = zip(*hl)
00041 self._canvas.axes.legend(handles, labels, loc='lower right')
00042
00043 def redraw(self):
00044 '''
00045 We fix the y axis and continually resize the x axis to encapsulate
00046 the entire domain, range of the battery profile.
00047
00048 @Todo : the domain is simply the data value, we could use
00049 '''
00050 self._canvas.axes.grid(True, color='gray')
00051
00052 xmax = 0
00053 for curve in self._curves.values():
00054 data_x, data_y, plot, min_max_y = curve
00055 if len(data_x) == 0:
00056 continue
00057
00058 xmax = max(xmax, data_x[-1])
00059 self._ymin = min(self._ymin, min_max_y[0])
00060 self._ymax = max(self._ymax, min_max_y[1] + 1)
00061 self._canvas.axes.set_xbound(lower=0, upper=xmax)
00062
00063 if self.dynamic_range:
00064 self._canvas.axes.set_ybound(lower=self._ymin, upper=self._ymax)
00065 else:
00066 self._canvas.axes.set_ybound(self.min_range, upper=self.max_range)
00067
00068
00069 for curve in self._curves.values():
00070 data_x, data_y, plot, min_max_y = curve
00071 plot.set_data(numpy.array(data_x), numpy.array(data_y))
00072
00073 self._canvas.draw()