Results 1 to 4 of 4

Thread: how to set the y-axis width?

  1. #1
    Join Date
    Aug 2017
    Location
    Munich, Germany
    Posts
    8
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Unix/X11

    Question how to set the y-axis width?

    Hello,

    i am playing with Qwt. Thanks for the great library! I have written an application with one or more plotters. In the first one i will draw a Chart of an financial market. In the plotter below i will draw as example an indicator. Please see the screenshot.
    Clipboard 1.jpg

    How can i set the width of the Y-axis on the right side of the plotter below?

    I would have the same width as the plotter above (with the candle-sticks). I tried so many things with plotter->axisWidget(QwtPlot::yRight)->resize() etc. but nothing work. Thanks for any suggestions!

    Best regards,
    johno


    EDIT: The vertical line is a QwtPlotMarker. I set the position with: plottMarker->setValue(chartPlotter->invTransform(QwtPlot::xBottom, pos.x()), 0); from the plotter above (with the signal: moved(QPoint) from QwtPlotPicker). It works, but it looks crazy because of the different width of the y-axis.
    Last edited by johno; 7th July 2021 at 03:01.

  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: how to set the y-axis width?

    Have a look at the plotmatrix example.

    Uwe

  3. The following user says thank you to Uwe for this useful post:

    johno (16th July 2021)

  4. #3
    Join Date
    Aug 2017
    Location
    Munich, Germany
    Posts
    8
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: how to set the y-axis width?

    Thank you Uwe, the plotmatrix example helps me!

    My solution:
    Qt Code:
    1. void MainWindow::updatePlotters(double lowerBound, double upperBound) {
    2. QwtScaleWidget *scaleWidget;
    3. QwtScaleDraw *scaleDraw;
    4. double maxExtent = 0;
    5. double extent = 0;
    6.  
    7. for(int i = 0; i < currentTrader->plotters.size(); i++) {
    8. currentTrader->plotters.at(i)->setAxisScale(QwtPlot::xBottom, lowerBound, upperBound);
    9. scaleWidget = currentTrader->plotters.at(i)->axisWidget(QwtPlot::yRight);
    10. scaleDraw = scaleWidget->scaleDraw();
    11. extent = scaleDraw->extent(scaleWidget->font());
    12. if(extent > maxExtent) maxExtent = extent;
    13. scaleDraw->setMinimumExtent(maxExtent);
    14. currentTrader->plotters.at(i)->updateLayout();
    15. currentTrader->plotters.at(i)->replot();
    16. }
    17. }
    To copy to clipboard, switch view to plain text mode 


    Added after 16 minutes:


    But a small problem still remains. I thought this would go away if the plotter's have the same drawing area/size. It is about the position of the QwtPlotMarker in the lower plotter (indicator-plotter). I set his position with the position of the QwtPlotPicker from the chart-plotter (the main plotter above).

    Qt Code:
    1. plotMarker->setValue(chartPlotter->invTransform(QwtPlot::xBottom, pos.x()), 0);
    To copy to clipboard, switch view to plain text mode 

    It is almost accurate, but on the right and left side it differs a little bit. In the middle it is ok. Any idea? I use QwtPlotMagnifier to zoom in the chart and give the plotter->axisScaleDiv(QwtPlot::xBottom).lowerBound() and upperBound to the other plotters. So far everything works well, expect the position of the QwtPlotMarker in the second (indicator-chart). But i think this has nothing to do with the zoom functionality.

    Any idea how I can fix / optimize this? Thanks a lot!

    Best regards johno



    Added after 20 minutes:


    better images:

    PlotMarker_04.jpg
    PlotMarker_05.jpg
    PlotMarker_06.jpg
    Attached Images Attached Images
    Last edited by johno; 16th July 2021 at 02:22.

  5. #4
    Join Date
    Aug 2017
    Location
    Munich, Germany
    Posts
    8
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: how to set the y-axis width?

    for your information: This problem is now sloved too! I have to set on all plotters: plotter->plotLayout()->setAlignCanvasToScales(false);

    Thanks a lot! Great library!!

Similar Threads

  1. Replies: 0
    Last Post: 23rd January 2017, 12:55
  2. yLeft axis constant width
    By baray98 in forum Qwt
    Replies: 4
    Last Post: 4th January 2013, 17:40
  3. Replies: 9
    Last Post: 3rd May 2011, 22:21
  4. QToolBox width fixed to maximum content width
    By ghorwin in forum Qt Programming
    Replies: 0
    Last Post: 10th July 2009, 10:58
  5. How to set QTableView width to width of horizontal header?
    By martinb0820 in forum Qt Programming
    Replies: 0
    Last Post: 2nd December 2008, 21:51

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.