PDA

View Full Version : Logarithmic scale problem



dimmes
19th November 2014, 16:11
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.

dimmes
19th November 2014, 20:54
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?

Uwe
20th November 2014, 07:33
To set a logarithmic scale for 1-100

plot->setAxisScaleEngine(QwtPlot::yLeft, new QwtLogScaleEngine(10));
plot->setAxisScale(QwtPlot::yLeft,1, 100);
plot->replot();

Uwe

dimmes
20th November 2014, 08:52
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.

Uwe
20th November 2014, 09:07
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

bY
14th June 2016, 11:28
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:
11978

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.

Uwe
14th June 2016, 13:30
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:


multiBars->setBaseline( 1.0 );Uwe

bY
14th June 2016, 15:53
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.

Uwe
14th June 2016, 16:11
Quoting from http://qwt.sourceforge.net/class_qwt_plot_abstract_bar_chart.html#adafbea42dd c3f7f639f2880a4bf683ad: "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

HappyCoder
17th June 2016, 10:38
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.