Results 1 to 3 of 3

Thread: PyQt, Qwt: Add a horizontal line (y=value)

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

    Default PyQt, Qwt: Add a horizontal line (y=value)

    Hi,

    I am trying to plot a simple horizontal line in my QwtPlot. I have a plot with DateTimeScaleEngine (X-Axis) and a 'normal' y-axis with values 0-255.
    How can I draw a horizontal line into this plot? This const. line will represent the mean value.

    I don't want to fill the curve, just a line.

    I tried f.e. this:

    Qt Code:
    1. self.meanline = QwtPlotCurve()
    2. self.meanline.setPen(QPen(Qt.green,2))
    3. self.meanline.setStyle(QwtPlotCurve.NoCurve)
    4. self.meanline.setCurveType(QwtPlotCurve.Yfx)
    5. self.meanline.attach(self.qwtPlot)
    To copy to clipboard, switch view to plain text mode 

    All my tests failed!

    Thanks!

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,313
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: PyQt, Qwt: Add a horizontal line (y=value)

    Quote Originally Posted by Lykanthropie View Post
    How can I draw a horizontal line into this plot?
    When this line is across the complete canvas you can use a marker. If the line is for a specific interval you need QwtPlotIntervalCurve from Qwt 6, what is not supported by PyQwt.

    You could also try to misuse QwtPlotCurve::Steps ( using curves with 2 points ). Otherwise you need to implement your own type of QwtPlotItem - what is more or less trivial for displaying a line.

    Uwe

  3. The following 2 users say thank you to Uwe for this useful post:

    Lykanthropie (13th January 2012), phyatt (21st September 2015)

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

    Default Re: PyQt, Qwt: Add a horizontal line (y=value)

    Thank you Uwe!

    Qt Code:
    1. self.meanline = QwtPlotMarker()
    2. self.meanline.setLineStyle(QwtPlotMarker.HLine)
    3. self.meanline.setLinePen(QPen(Qt.green, 1))
    4. self.meanline.attach(self.qwtPlot)
    5. .....
    6. self.meanline.setYValue(self.mean(numvalues))
    To copy to clipboard, switch view to plain text mode 

    It's working!

  5. The following user says thank you to Lykanthropie for this useful post:

    phyatt (21st September 2015)

Similar Threads

  1. Read gzip file line-by-line
    By The_Fallen in forum Qt Programming
    Replies: 4
    Last Post: 6th September 2011, 13:41
  2. Horizontal line in QTextDocument
    By Ginsengelf in forum Qt Programming
    Replies: 2
    Last Post: 11th February 2011, 09:37
  3. Replies: 3
    Last Post: 13th August 2010, 11:50
  4. Upgrading from PyQt 4.5 to PyQt 4.7
    By RogerCon in forum Installation and Deployment
    Replies: 0
    Last Post: 14th July 2010, 18:52
  5. Replies: 1
    Last Post: 21st November 2009, 08:29

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.