Results 1 to 6 of 6

Thread: Qwt X-Axis with Date, correct distance

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2012
    Posts
    5
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Qwt X-Axis with Date, correct distance

    Hi there,

    I have a list with some tuples like [(datetime.date, int), (datetime.date, int),].

    I can already plot one date per tick, but I want to have the correct distance between two different dates.

    Qt Code:
    1. class TimeScaleDraw(QwtScaleDraw):
    2. def __init__(self, dates):
    3. QwtScaleDraw.__init__(self)
    4. self.dates = dates
    5. self.setLabelAlignment(Qt.AlignLeft | Qt.AlignBottom)
    6. self.setLabelRotation(270)
    7.  
    8.  
    9. def label(self, value):
    10. if value % 1 == 0 and int(value) < len(self.dates):
    11. return QwtText(str(self.dates[int(value)]))
    12. else:
    13. return QwtText('')
    To copy to clipboard, switch view to plain text mode 

    I have no idea how I can create a 'time true' axis.

    The dates for example are 2010-02-01, 2010-10-14, 2010-11-11, 2011-03-28.

    I am using PyQt4.Qwt5.
    Last edited by Lykanthropie; 2nd January 2012 at 15:51.

Similar Threads

  1. Date Scale for X-Axis
    By mishani99 in forum Qwt
    Replies: 3
    Last Post: 6th September 2011, 11:40
  2. Replies: 1
    Last Post: 2nd August 2011, 18:01
  3. Replies: 5
    Last Post: 26th June 2011, 11:43
  4. Time/Date Axis
    By sigger in forum Qwt
    Replies: 12
    Last Post: 1st May 2011, 09:55
  5. Replies: 1
    Last Post: 5th January 2010, 21:00

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
  •  
Qt is a trademark of The Qt Company.