Results 1 to 2 of 2

Thread: Multiple legends with single plot?

  1. #1
    Join Date
    Jan 2014
    Posts
    36
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Multiple legends with single plot?

    I'm wondering if it's possible to have multiple legends connected to a single plot, but have the legends show different curves? And if so, the obvious follow up is how to go about doing it...

    I've got a setup where the user can choose to display 1-16 curves per plot. Each individual curve has completely different range values, some go from 0 to 12,000, others go from 0 to 1, others go from -127 to +128, etc. So right now I've got it set up where I'm using both the right and left axes, with the left axis reserved for "big" value ranges (like the 0 to 12,000 curve) and the right axis for smaller ranges (like to 0 to 1). I'm currently using a single legend to the right of the plot. As I've been playing around with it and showing it to coworkers, we're in agreement that it's confusing that some of the curves are using the left axis, some are using the right axis, but all of the curves are showing up in the single legend to the right.

    So I'd like to have a horizontal layout that looks like:
    | left legend | left axis | plot | right axis | right legend |

    Where the curves that are using the left axis only show up in the left legend, and curves that are using the right axis only show up in the right legend

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

    Default Re: Multiple legends with single plot?

    Te layout system of QwtPlot is not able to handle more than one legend, but you can have as many legends as you want to, when you are willing to take care of their layouts yourself. On screen this is easy using standard Qt layouts, but when using QwtPlotRenderer you might need to implement some layout code yourself.

    Instead of using QwtPlot::insertLegend you have to handle the QwtPlot::legendDataChanged() signal yourself. By overloading QwtPlotItem::legendData() you could add some extra information to the legend data, so that you know later what item goes to what legend.

    Uwe

Similar Threads

  1. how to Plot multiple graphs of multiple range ?
    By karankumar1609 in forum Qt Programming
    Replies: 2
    Last Post: 15th July 2013, 11:22
  2. Replies: 5
    Last Post: 26th October 2012, 08:46
  3. Multiple Legends
    By Pandimensional in forum Qwt
    Replies: 5
    Last Post: 17th August 2012, 08:02
  4. Draw a single point into a qwt plot
    By Qwt_beginner in forum Qwt
    Replies: 2
    Last Post: 12th December 2011, 09:32
  5. Replies: 4
    Last Post: 15th October 2008, 13:24

Tags for this Thread

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.