PDA

View Full Version : Changing data in spectogram



stefan
19th July 2011, 06:00
Hi!

I'm trying to modify spectogram example to plot interpolated function z(x,y) based on 2D array Z and 1D arrays X and Y. I made interpolation algorithm and function
double value(double x, double y), but i have a problem to implement those arrays.
I tried with pointers to arrays in SpectrogramData, but I cant get it work.

What's the easiest way to provide those arrays to value function?
Second step is to change values of arrays and replot...

Thanks!

P.S.
class SpectrogramData: public QwtRasterData

Uwe
19th July 2011, 07:41
What's the easiest way to provide those arrays to value function?
Use QwtMatrixRasterData ( it implements next next neighbour and bilinear interpolation ).


Second step is to change values of arrays and replot...
The spectrogram caches the rendered image, that needs to be invalidated before you replot. The spectrogram class implicitely invalidates this image, when you use its public API. When you want to change the array behind the back of the class you have to call spectrogram->invalidateCache() manually.

Uwe

Onanymous
19th July 2011, 08:32
The spectrogram class implicitely invalidates this image, when you use its public API. When you want to change the array behind the back of the class you have to call spectrogram->invalidateCache() manually.
Uwe
Thanks a lot for that note. This should be written in big letters somewhere in the documentation of spectrogram.

stefan
21st July 2011, 00:35
Thanks, it's working!

stefan
23rd July 2011, 03:39
Hi,
I have another issue regarding spectogram example, thus I'll continue on this post.

When I change intervals

setInterval( Qt::XAxis, QwtInterval( -1.5, 1.56 ) );
The plot is actually drawn from -1.5 to 2.0
It probably rounds limits.. But I dont want that.
How can I prevent that? How can I crop a plot? I dont mind if the last value on the axis is 1.5

Thank you

Uwe
24th July 2011, 20:51
To avoid, that tick labels close to the borders extend the canvas you have to set:

plot->plotLayout()->setAlignCanvasToScales(true);

Next you have to decide if you want to use auto scaling or not. If not you can assign the axes scales manually.


plot->setAxisScale( QwtPlot::xBottom, ... );
plot->setAxisScale( QwtPlot::yLeft, ... );
...

If you want to have autoscaling, but you want to exclude your spectrogram from participating:


spectrogram->setItemAtribute( QwtPlotItem::AutoScale, false );

Or if you want to have autoscaling for your spectrogram , but you don't want the autoscaler to align the borders of the scales:


plot->axisScaleEngine( QwtPlot::xBottom )->setAttribute(
QwtScaleEngine::Floating, true );
plot->axisScaleEngine( QwtPlot::yLeft )->setAttribute(
QwtScaleEngine::Floating, true );
...

HTH,
Uwe

stefan
25th July 2011, 06:31
Yes, that's exactly what I'm looking for!

plotLayout()->setAlignCanvasToScales(true);
setAxisScale( QwtPlot::xBottom,X->first(),X->last());
setAxisScale( QwtPlot::yLeft,Y->first(),Y->last());
colorAxis->setColorMap(QwtDoubleInterval(zMin, zMax),d_spectrogram->colorMap());
setAxisScale(QwtPlot::yRight,zMin,zMax);

Uwe, you are a true QwtMaster :) Thanks!

Uwe
25th July 2011, 07:32
No, obviously you want autoscaling. Then this is your code ( of course with the same result ):


plotLayout()->setAlignCanvasToScales(true);
axisScaleEngine( QwtPlot::xBottom )->setAttribute(
QwtScaleEngine::Floating, true );
axisScaleEngine( QwtPlot::yLeft )->setAttribute(
QwtScaleEngine::Floating, true );
colorAxis->setColorMap(QwtDoubleInterval(
zMin, zMax), d_spectrogram->colorMap());
setAxisScale(QwtPlot::yRight, zMin, zMax);

Uwe

marc2050
31st July 2011, 13:35
Hi.
Following on this topic. I'm trying to use the spectrogram to plot and visualize some elevation data...
I've only the intensity values (height of the mountains) at certain points in the x,y coordinates. Total about 20 heights.
How do I input the raster data so that I could see the spectrogram being interpolated inbetween the mountain heights?
The entire area map is about 400x400 in length and width.
Thank you for any advise.

Uwe
1st August 2011, 09:02
Following on this topic.
This question doesn't follow - please start a new thread for a unrelated posting,

Uwe

dzemomona12
8th September 2011, 16:03
This doesn't work for me :(

Uwe
8th September 2011, 19:00
This doesn't work for me :(
You failed with starting a new thread for unrelated postings ?

Uwe