Hi, i'm implementing my own QwtScaleDraw like that:
def __init__(self, baseTime):
#QTime baseTime
self.baseTime = baseTime
self.setLabelAlignment(Qt.AlignLeft | Qt.AlignBottom)
self.setLabelRotation(-25.0)
def label(self, secs):
upTime = self.baseTime.addSecs(secs)
upTime = upTime.toString('dd MM yy hh:mm:ss')
class TimeScaleDraw(QwtScaleDraw):
def __init__(self, baseTime):
QwtScaleDraw.__init__(self)
#QTime baseTime
self.baseTime = baseTime
self.setLabelAlignment(Qt.AlignLeft | Qt.AlignBottom)
self.setLabelRotation(-25.0)
def label(self, secs):
upTime = self.baseTime.addSecs(secs)
upTime = upTime.toString('dd MM yy hh:mm:ss')
return QwtText(upTime)
To copy to clipboard, switch view to plain text mode
then I use it this way:
ticks = [0, 60, 120]
div.setInterval(ticks[0], ticks[len(ticks)-1])
draw
= TimeScaleDraw
(QDateTime(self.
main.
timeMin))draw.setScaleDiv(div)
self.
plot.
setAxisScaleDraw(QwtPlot.
xBottom, draw
)self.
plot.
setAxisScale(QwtPlot.
yLeft, self.
main.
valueMin, self.
main.
valueMax)
ticks = [0, 60, 120]
div = QwtScaleDiv()
div.setInterval(ticks[0], ticks[len(ticks)-1])
div.setTicks(QwtScaleDiv.MinorTick, [])
div.setTicks(QwtScaleDiv.MediumTick, [])
div.setTicks(QwtScaleDiv.MajorTick, ticks)
draw = TimeScaleDraw(QDateTime(self.main.timeMin))
draw.setScaleDiv(div)
self.plot.setAxisScaleDraw(QwtPlot.xBottom, draw)
self.plot.setAxisScale(QwtPlot.yLeft, self.main.valueMin, self.main.valueMax)
To copy to clipboard, switch view to plain text mode
I'd like to have only 3 ticks (where there actually are values) on my x axis, but some how I get more ticks added (see screen shot). what do i do wrong? any suggestion?
Bookmarks