Results 1 to 10 of 10

Thread: Logarithmic scale problem

  1. #1
    Join Date
    Nov 2014
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Logarithmic scale problem

    Hi,

    I plot some values that range from 0~1024, and i want to use a logarithmic scale in y axis.

    ->setAxisScaleEngine(QwtPlot::yLeft, new QwtLogScaleEngine(10));
    The problem is that values are drawn from the top and the scale take as maximum value 1e+20, while the minimum don't surpass 1.
    i tried with ->setAxisScale(QwtPlot::yLeft,1, 100); and change with variable combinations the min, max values, but still the values are drawn from the top.
    Iam using qwt 5.0.2

    thanks in advance.

  2. #2
    Join Date
    Nov 2014
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Logarithmic scale problem

    i think i've found a solution to my problem but it is temporary and not the appropriate. I understood tha there was a linear connection between the plotted values while the axis scale was logarithmic, i changed the line style from line to dots and it worked. however i 'd like to plot those values (0~1024) in log scale (1~1000) without converting them in logarithm and with the style of line. is that possible?

  3. #3
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,277
    Thanked 871 Times in 819 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Logarithmic scale problem

    To set a logarithmic scale for 1-100
    Qt Code:
    1. plot->setAxisScaleEngine(QwtPlot::yLeft, new QwtLogScaleEngine(10));
    2. plot->setAxisScale(QwtPlot::yLeft,1, 100);
    3. plot->replot();
    To copy to clipboard, switch view to plain text mode 

    Uwe

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

    dimmes (20th November 2014)

  5. #4
    Join Date
    Nov 2014
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Logarithmic scale problem

    Hi Uwe,

    i have made it and i managed to draw the scale but my problem is that i want to plot the values as lines and not as dots, i was thinking to connect the dots with qwt marker but the connection is only horizontial or vertically! is there any solution to plot those values,in log scale, with line connection?

    thanks.

  6. #5
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,277
    Thanked 871 Times in 819 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Logarithmic scale problem

    The line style of a curve is completely unrelated to the fact, that you have a logarithmic scale.
    Have a look at the bode example showing a logarithmic scale with curves in QwtPlotCurve::Lines style.

    Uwe

  7. #6
    Join Date
    Jun 2016
    Posts
    2

    Default Re: Logarithmic scale problem

    Hi there, hi Uwe,
    i think i have the same problem. I use QwtPlotMultiBarChart and QwtLogScaleEngine. But the bars are drawn from the top down to the correct values.
    I stripped it to this:
    m_pPlot = new QwtPlot(this);
    m_pPlot->setCanvasBackground(Qt::white);
    m_pPlot->setAxisScaleEngine(QwtPlot::yLeft, new QwtLogScaleEngine());
    m_pPlot->setAxisScale(QwtPlot::yLeft, 1, 500);
    m_pPlot->resize(460,460);
    m_pPlot->show();

    QVector< QVector<double> >* allValues = new QVector< QVector<double> >();

    for(int s=1; s<=3; s++)
    {
    QVector<double>* sampleValues = new QVector<double>;
    sampleValues->append(10*s);
    sampleValues->append(100*s);
    allValues->append(*sampleValues);
    }

    QwtPlotMultiBarChart* multiBars = new QwtPlotMultiBarChart();
    multiBars->setSamples(*allValues);
    multiBars->attach(m_pPlot);
    m_pPlot->replot();
    Inside my Linix and on Windows the problem appears, looking like this:
    Bildschirmfoto1.png

    On an embedded linux device from Garz & Fricke it's ok, it looks how it should look.
    The Qwt files are compiled into the application file.
    I tried qwt 6.1.0 and 6.1.3.

  8. #7
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,277
    Thanked 871 Times in 819 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Logarithmic scale problem

    The bars are painted from the baseline of the item to the value. As the default setting for the baseline is 0 you have something invalid for a logarithmic scale.
    Guess adding the following line is what you are looking for:

    Qt Code:
    1. multiBars->setBaseline( 1.0 );
    To copy to clipboard, switch view to plain text mode 
    Uwe

  9. #8
    Join Date
    Jun 2016
    Posts
    2

    Default Re: Logarithmic scale problem

    Thats exactly what i need. Thank you.
    Actually i am often confused with the assigned names for member, functions, etc. in Qwt, which i can't classify.

  10. #9
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,277
    Thanked 871 Times in 819 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Logarithmic scale problem

    Quoting from http://qwt.sourceforge.net/class_qwt...f2880a4bf683ad: "The baseline is the origin for the chart. Each bar is painted from the baseline in the direction of the sample value."
    What would you consider to be better than "baseline" - in this particular context ?

    Uwe

  11. #10
    Join Date
    Jul 2015
    Posts
    87
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Logarithmic scale problem

    improvement suggestion:

    The default value for the baseline is 0 for linear scales.
    The default value for the baseline is 1 for logarithmic scales.

    That could be an improvement for Qwt.

Similar Threads

  1. Replies: 2
    Last Post: 21st July 2013, 20:35
  2. QWT::Knob with the logarithmic scale
    By hack006 in forum Qwt
    Replies: 1
    Last Post: 2nd April 2011, 16:57
  3. logarithmic scales
    By sergio486 in forum Qwt
    Replies: 2
    Last Post: 22nd December 2010, 17:05
  4. logarithmic scale
    By Times in forum Qwt
    Replies: 2
    Last Post: 1st July 2008, 15:41
  5. Replies: 2
    Last Post: 14th March 2008, 12:38

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.