title: How can I draw TextItems over candlesticks in pyqtgraph?
body: <p>I'm trying to plot candlesticks with TextItems that show every price level for each candle.</p>
  
  <p>I referred to 'custom graphics' example and just added a method to CandlestickItem as follows.</p>
  
  <pre><code>class CandlestickItem(pg.GraphicsObject):
      def __init__(self, data, plt):
          pg.GraphicsObject.__init__(self)
          self.data = data
          self.generatePicture()
          self.plt = plt
          self.add_text()
  
      def generatePicture(self):
          self.picture = QtGui.QPicture()
          p = QtGui.QPainter(self.picture)
          p.setPen(pg.mkPen('w'))
          w = (self.data[1][0] - self.data[0][0]) / 3.
          for (t, open, close, min, max) in self.data:
              p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max))
              if open &gt; close:
                  p.setBrush(pg.mkBrush('r'))
              else:
                  p.setBrush(pg.mkBrush('g'))
              p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open))
          p.end()
  
      def paint(self, p, *args):
          p.drawPicture(0, 0, self.picture)
  
      def boundingRect(self):
          return QtCore.QRectF(self.picture.boundingRect())
  
      def add_text(self):
          prices = self.data
  
          for price in prices:
  
              index = price[0]
              high = max(price[1:])
              low = min(price[1:])
  
              price_range = np.arange(low, high+1, 1)
  
              for price_level in price_range:
  
                  text = 'text_' + str(price_level)
  
                  text = pg.TextItem(str(price_level), anchor=(-0.1, 0.5))
                  plt.addItem(text)
                  text.setPos(index, price_level)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/yYDhH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yYDhH.png" alt="enter image description here"></a>
  I have two questions:</p>
  
  <p>1) How can I make it show the TextItems over the candlesticks?</p>
  
  <p>2) Are there better ways to show TextItems other than the way I chose? I wonder if this way would harm the performance if there are many candles and the step size is smaller, for example: 0.01.</p>