full_size_data_plot.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # License: BSD
4 # https://raw.github.com/yujinrobot/kobuki_desktop/master/kobuki_qtestsuite/LICENSE
5 #
6 ##############################################################################
7 # Imports
8 ##############################################################################
9 
10 import operator
11 import numpy
12 
13 #from rqt_plot.qwt_data_plot import QwtDataPlot
14 from rqt_plot.data_plot import DataPlot
15 
16 ##############################################################################
17 # Classes
18 ##############################################################################
19 
21  def __init__(self, parent=None):
22  super(FullSizeDataPlot, self).__init__(parent)
23  self.max_range = 180
24  self.min_range = 0
25  self.dynamic_range = False
26  self._ymin = 0
27  self._ymax = 0
28 
29  def reset(self):
30  self._ymin = 0
31  self._ymax = 0
32 
33  ######################################
34  # Overrides
35  ######################################
36  def _update_legend(self):
37  handles, labels = self._canvas.axes.get_legend_handles_labels()
38  if handles:
39  hl = sorted(zip(handles, labels), key=operator.itemgetter(1))
40  handles, labels = zip(*hl)
41  self._canvas.axes.legend(handles, labels, loc='lower right')
42 
43  def redraw(self):
44  '''
45  We fix the y axis and continually resize the x axis to encapsulate
46  the entire domain, range of the battery profile.
47 
48  @Todo : the domain is simply the data value, we could use
49  '''
50  self._canvas.axes.grid(True, color='gray')
51  # Set axis bounds
52  xmax = 0
53  for curve in self._curves.values():
54  data_x, data_y, plot, min_max_y = curve
55  if len(data_x) == 0:
56  continue
57 
58  xmax = max(xmax, data_x[-1])
59  self._ymin = min(self._ymin, min_max_y[0])
60  self._ymax = max(self._ymax, min_max_y[1] + 1)
61  self._canvas.axes.set_xbound(lower=0, upper=xmax)
62 
63  if self.dynamic_range:
64  self._canvas.axes.set_ybound(lower=self._ymin, upper=self._ymax)
65  else:
66  self._canvas.axes.set_ybound(self.min_range, upper=self.max_range)
67 
68  # Set plot data on current axes
69  for curve in self._curves.values():
70  data_x, data_y, plot, min_max_y = curve
71  plot.set_data(numpy.array(data_x), numpy.array(data_y))
72 
73  self._canvas.draw()


kobuki_qtestsuite
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:53:02