PDA

View Full Version : How to set the fixed start and enf od the axis value?



wang9658
23rd June 2012, 15:50
I want to get an axis like this:
7891

The axis from 20-20K.
between 20 and 100, the step is 10
between 100-1K, the step is 100
between 1K-10K, the step is 1000
and 10K-20K, the step is 10k.

I copy some code from qwt example,like the following:


logSpace(frequency, 20000, 20,20000);
...
currentCurve->setSamples(frequency, amplitude, 20000);
...
#define qExp(x) ::exp(x)
#define qAtan2(y, x) ::atan2(y, x)

static void logSpace( double *array, int size, double xmin, double xmax )
{
if ( ( xmin <= 0.0 ) || ( xmax <= 0.0 ) || ( size <= 0 ) )
return;

const int imax = size - 1;

array[0] = xmin;
array[imax] = xmax;

const double lxmin = log( xmin );
const double lxmax = log( xmax );
const double lstep = ( lxmax - lxmin ) / double( imax );

for ( int i = 1; i < imax; i++ )
array[i] = qExp( lxmin + double( i ) * lstep );
}


But I got the following display:
7892
, it's not from 20-20k. changed to 10-100k.

What I can do?

Uwe
23rd June 2012, 17:16
And all of the intervals should have the same size in pixels - like for a log10 ( see the bode example ) based scale ?

Uwe

wang9658
24th June 2012, 01:17
Sure, That's I want. But qwt can only display a complete major, for example, 10-100, but not 20-100

Added after 12 minutes:

It's very strange,

If set the scale range to 20-20k, it's ok.
setAxisScale(xBottom, 20,20000);

But yesterday, it did not work.