def label(self, val): if str(self._labelFormat) == "": return qwt.QwtText() if self._labelFormat is None: return qwt.QwtScaleDraw.label(self, val) else: return qwt.QwtText(self._labelFormat % val)
def label(self, val): try: index = self._positions.index(val) # try to find an exact match except: index = None # It won't show any label # use the index of the closest position #index = (numpy.abs(self._positionsarray - val)).argmin() if index is not None: return qwt.QwtText(self._labels[index]) else: qwt.QwtText()
def label(self, val): if str(self._labelFormat) == "": return qwt.QwtText() # From val to a string with time t = datetime.fromtimestamp(val) try: # If the scaleDiv was created by a DateTimeScaleEngine it has a _datetimeLabelFormat s = t.strftime(self._datetimeLabelFormat) except AttributeError as e: print( "Warning: cannot get the datetime label format (Are you using a DateTimeScaleEngine?)" ) s = t.isoformat(' ') return qwt.QwtText(s)
class TaurusTimeScaleDraw(FancyScaleDraw): def __init__(self, *args): FancyScaleDraw.__init__(self, *args) def setDatetimeLabelFormat(self, format): self._datetimeLabelFormat = format def datetimeLabelFormat(self): return self._datetimeLabelFormat def label(self, val): if str(self._labelFormat) == "": return qwt.QwtText() # From val to a string with time t = datetime.fromtimestamp(val) try: # If the scaleDiv was created by a DateTimeScaleEngine it has a _datetimeLabelFormat s = t.strftime(self._datetimeLabelFormat) except AttributeError, e: print "Warning: cannot get the datetime label format (Are you using a DateTimeScaleEngine?)" s = t.isoformat(' ') return qwt.QwtText(s)
def label(self, val): if val >= 0: s = "+%s" % str(timedelta(seconds=val)) else: s = "-%s" % str(timedelta(seconds=-val)) return qwt.QwtText(s)