Example #1
0
  class HistogramLineMarker (object):
    """Helper class implementing a line marker for a histogram plot""";
    def __init__ (self,plot,color="black",linestyle=Qt.DotLine,align=Qt.AlignBottom|Qt.AlignRight,z=90,label="",zlabel=None,linewidth=1,spacing=2,
                  yaxis=QwtPlot.yRight):
      self.line = TiggerPlotCurve();
      self.color = color = color if isinstance(color,QColor) else QColor(color);
      self.line.setPen(QPen(color,linewidth,linestyle));
      self.marker = TiggerPlotMarker();
      self.marker.setLabelAlignment(align);
      try:
        self.marker.setSpacing(spacing);
      except AttributeError:
        pass;
      self.setText(label);
      self.line.setZ(z);
      self.marker.setZ(zlabel if zlabel is not None else z);
      # set axes -- using yRight, since that is the "markup" z-axis
      self.line.setAxis(QwtPlot.xBottom,yaxis);
      self.marker.setAxis(QwtPlot.xBottom,yaxis);
      # attach to plot
      self.line.attach(plot);
      self.marker.attach(plot);

    def show (self):
      self.line.show();
      self.marker.show();

    def hide (self):
      self.line.hide();
      self.marker.hide();

    def setText (self,text):
      label = QwtText(text);
      label.setColor(self.color);
      self.marker.setLabel(label);