Results 1 to 3 of 3

Thread: Multiple Y-axis plot

  1. #1
    Join Date
    Sep 2015
    Posts
    36
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Multiple Y-axis plot

    I'm currently trying to make it possible for user to put few curves on the same plot. If it's going to be useful in any way I need to have multiple Y scales, so I can rescale every curve separately and give it it's own Y scale (X is time, so it's common for every sample). Unfortunately Qwt supports only 2 Y scales on default. I tried to cheat a little and it worked, but I'm not eager to trust this method.

    Qt Code:
    1. QwtScaleWidget* scale2 = new QwtScaleWidget();
    2. scale2->setAlignment(QwtScaleDraw::RightScale);
    3. QwtScaleWidget* scale3 = new QwtScaleWidget();
    4. scale->setBorderDist(6,33); // I really think it's a bad idea
    5. scale2->setBorderDist(6,33);
    6. scale3->setBorderDist(6,33);
    7.  
    8. ui->leftLayout->addWidget(scale,0,0,1,1,0);
    9. ui->rightLayout->addWidget(scale2,0,0,1,1,0);
    10. ui->leftLayout->addWidget(scale3,0,1,1,1,0);
    To copy to clipboard, switch view to plain text mode 

    I did what you see above. Plot widget has two grid layouts on it's left and right, and I just put these scales inside. X axis is common and I use default one from QwtPlot (so I don't have to fit another one). Unfortunately these scales are not willing to be perfectly adjusted to plot just like that, so I needed to add setBorderDist. It's now perfectly fitted using trial and error method, and it SEEMS to work for all resolutions, but I don't think it will fit all the time in every case.

    May I know if there is a better and less risky way to achieve that?

    Also adding widgets to layout is pretty painful, because I can only add scale to the right of previous scale. So it's working well on the right side when user clicks "show me another plot" checkbox, and it does not work well on the left, so I would have to clean leftLayot from all widgets and add them again from a scratch in correct order. It has to work in real-time (showing new plots, hiding others and so on), so I can't really do it using designer.

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

    Default Re: Multiple Y-axis plot

    See https://svn.code.sf.net/p/qwt/code/b...-6.1-multiaxes.

    In opposite to its name the code is ~ in sync with trunk ( = Qwt 6.2 ) and is intended to be merged into the mainline as Qwt 6.3.

    Uwe

  3. #3
    Join Date
    Sep 2015
    Posts
    36
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Multiple Y-axis plot

    Ok, it's standalone Qwt version. I did some tests and it seems to work, thanks!
    Last edited by Khaine; 25th March 2016 at 13:03.

Similar Threads

  1. Replies: 2
    Last Post: 11th February 2015, 08:43
  2. how to Plot multiple graphs of multiple range ?
    By karankumar1609 in forum Qt Programming
    Replies: 2
    Last Post: 15th July 2013, 12:22
  3. Axis not fit with the plot
    By Nicho in forum Qwt
    Replies: 14
    Last Post: 28th June 2013, 13:28
  4. Need help formatting plot axis
    By Jayl in forum Qwt
    Replies: 2
    Last Post: 8th April 2013, 19:20
  5. Replies: 9
    Last Post: 3rd May 2011, 22:21

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.