Results 1 to 5 of 5

Thread: Scatter plot with custom symbols

  1. #1
    Join Date
    Dec 2009
    Posts
    24
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Scatter plot with custom symbols

    Hi there,

    I'm trying to put together a scatter plot widget where each symbol can be customized to convey a 3rd dimension of data...
    by changing the size and/or the color of the symbol for example
    (something in that fashion if not clear:http://matplotlib.sourceforge.net/pl...sked.hires.png)

    I modified a bit the realtime plot example, setting up a new symbol each time a data point is appended but
    when the widget is resized or zoomed in, everything is redrawn using the current last symbol....

    It's probably not that complicated but I think I need an eye opener from someone...
    as for now, the solution I see is creating a new drawSymbols function that would take an array of QwtSymbol as input...

    Thanks for any help

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

    Default Re: Scatter plot with custom symbols

    In the devlopment branch of Qwt ( SVN trunk ) you can find an item ( QwtPlotCurve3D ), that maps the z value into colors. There is also code available for mapping the z value into the symbol size, but has not been committed yet. But be warned the final design of this class is not decided, so better copy it into your project.

  3. #3
    Join Date
    Dec 2009
    Posts
    24
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Scatter plot with custom symbols

    I just checked that out thanks!

    Just for my education, did you actually considered using an array of symbols?
    I see that you create a new symbol before drawing and delete it straight away....
    Is there any performance concern in doing that?

    On an unrelated topic, I saw a comment of yours about OpenGL, saying that it would be a bad performer as
    the widget has to redraw itself entirely all the time...
    It's true, but if you use modern OpenGL and store the data on the GPU (because you used VBOs), a redraw operation
    should not be that costly... but even if it is, OpenGL has FrameBuffer Objets... which would be used in the same fashion you cache into a Pixmap currently....

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

    Default Re: Scatter plot with custom symbols

    Just for my education, did you actually considered using an array of symbols?
    The basic idea of this class is to map the z value to a colored dot via a color map. But there are so many other ways how the z value could be displayed ( symbol type/size, direction of an arrow symbol ... ), that its hard to design a class, that is able to handle them all.

    Maybe I will introduce a base class for a 3D points curve with a pure virtual method:
    "virtual void drawPoint(const QPointF &pos, double z) = 0", but in the end deriving from QwtPlotSeriesItem<QwtDoublePoint3D> is also an easy way to implement optimized painting code.
    Quote Originally Posted by jcox23 View Post
    I see that you create a new symbol before drawing and delete it straight away....
    Is there any performance concern in doing that?
    Sure it is and don't use it for trillions of points - but this doesn't make much sense for this type of representation at all.
    On an unrelated topic, I saw a comment of yours about OpenGL, saying that it would be a bad performer as the widget has to redraw itself entirely all the time...
    It's true, but if you use modern OpenGL and store the data on the GPU (because you used VBOs), a redraw operation should not be that costly... but even if it is, OpenGL has FrameBuffer Objets... which would be used in the same fashion you cache into a Pixmap currently....
    My note was about incremental painting, something you can see in the realtime/oscilloscope examples. The interesting fact is, that for certain situations/environments you would have worse performance using the hardware accelerated path of OpenGL (that is not supported by Qwt yet).

    Uwe

  5. #5
    Join Date
    Dec 2009
    Posts
    24
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Scatter plot with custom symbols

    Before using the trunk version (btw the friedberg example is gorgeous), I modified the 5.2.0 version...messing around the DrawSymbols method
    to get a better understanding of what's going on in there...

    I managed to get something close to what I wanted...see attached

    Quote Originally Posted by Uwe View Post
    The basic idea of this class is to map the z value to a colored dot via a color map. But there are so many other ways how the z value could be displayed ( symbol type/size, direction of an arrow symbol ... ), that its hard to design a class, that is able to handle them all.
    That's why I thought first of an array of symbols...
    DrawSymbols would expect an array of symbols, the user being in total control
    of what to put in there... implementing the 3d in whatever aspect...

    The way you implemented QwtPlotCurve3D is of course more user-friendly...

    Quote Originally Posted by Uwe View Post
    Maybe I will introduce a base class for a 3D points curve with a pure virtual method:
    "virtual void drawPoint(const QPointF &pos, double z) = 0", but in the end deriving from QwtPlotSeriesItem<QwtDoublePoint3D> is also an easy way to implement optimized painting code.

    Sure it is and don't use it for trillions of points - but this doesn't make much sense for this type of representation at all.
    Quote Originally Posted by Uwe View Post
    My note was about incremental painting, something you can see in the realtime/oscilloscope examples. The interesting fact is, that for certain situations/environments you would have worse performance using the hardware accelerated path of OpenGL (that is not supported by Qwt yet).

    Uwe
    I thought OpenGL would be a way to get rid of these platform-dependant stuff concerning incremental painting, and still having very good performance...
    rendering to a FrameBuffer, so you only render the framebuffer, instead rendering all the points each time a point is added... I cant state that as a fact though...
    and recent blog posts of the Qt team showed as you said that sometimes OpenGL is not very faster than X11...
    Attached Images Attached Images

Similar Threads

  1. Labeling scatter plot points
    By hamid ghous in forum Qwt
    Replies: 1
    Last Post: 29th October 2009, 06:35
  2. Graphic view for scatter plot
    By hamid ghous in forum Qt Programming
    Replies: 2
    Last Post: 11th August 2009, 15:27
  3. Scatter plot with many colors
    By DKL1972 in forum Qwt
    Replies: 4
    Last Post: 29th June 2008, 11:15
  4. Scatter graph
    By elcuco in forum Qwt
    Replies: 5
    Last Post: 27th December 2007, 11:48

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.