Results 1 to 13 of 13

Thread: PyQT QwtScaleDiv adds ticks to axis

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2011
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default PyQT QwtScaleDiv adds ticks to axis

    Hi, i'm implementing my own QwtScaleDraw like that:
    Qt Code:
    1. class TimeScaleDraw(QwtScaleDraw):
    2. def __init__(self, baseTime):
    3. QwtScaleDraw.__init__(self)
    4. #QTime baseTime
    5. self.baseTime = baseTime
    6. self.setLabelAlignment(Qt.AlignLeft | Qt.AlignBottom)
    7. self.setLabelRotation(-25.0)
    8.  
    9. def label(self, secs):
    10. upTime = self.baseTime.addSecs(secs)
    11. upTime = upTime.toString('dd MM yy hh:mm:ss')
    12. return QwtText(upTime)
    To copy to clipboard, switch view to plain text mode 
    then I use it this way:
    Qt Code:
    1. ticks = [0, 60, 120]
    2. div = QwtScaleDiv()
    3. div.setInterval(ticks[0], ticks[len(ticks)-1])
    4. div.setTicks(QwtScaleDiv.MinorTick, [])
    5. div.setTicks(QwtScaleDiv.MediumTick, [])
    6. div.setTicks(QwtScaleDiv.MajorTick, ticks)
    7. draw = TimeScaleDraw(QDateTime(self.main.timeMin))
    8. draw.setScaleDiv(div)
    9. self.plot.setAxisScaleDraw(QwtPlot.xBottom, draw)
    10. 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?
    Attached Images Attached Images
    Last edited by mbernasocchi; 16th March 2011 at 11:59. Reason: updated contents

Similar Threads

  1. Replies: 12
    Last Post: 18th May 2011, 20:40
  2. Replies: 1
    Last Post: 20th April 2011, 16:23
  3. Replies: 0
    Last Post: 9th August 2010, 10:46
  4. Replies: 1
    Last Post: 30th July 2010, 07:23
  5. Replies: 1
    Last Post: 16th March 2010, 15:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.