Dear Patrick,

thanks for your nice answer and pointing me to the new way to do 
transformations and scaling!

Kind regards
feli_x

Patrick schrieb am Dienstag, 21. September 2021 um 05:57:47 UTC+2:

> Hi,
>
> There is nothing fundamentally wrong with what you are doing. You can just 
> keep creating ImageItems and adding them to the plot with appropriate scale 
> and translate transforms applied. I have no idea how many you'd need to add 
> before you run into performance issues. Obviously, with a very large data 
> set you'd want to slice and/or downsample your data depending on the view 
> range of the plot. If your spectral slices are small (a few data points) 
> you may want to merge slices together (say 256--1024 pixels wide).
>
> Here's some code which demonstrates the "new" way to do the translate and 
> scale:
>
> # ...
> # plot = pyqtgraph plotitem
>
> # Keep list of image items
> spec_images = []
>
> # Loop through existing data slices
> # (or add each slice as they are acquired)
> for specslice in specslices:
>     # ...
>     # t = time axis coordinates of slice
>     # f = frequency axis of slice(s)
>     # Compute scale factors for each image dimension
>     # (if identical for each slice, could compute outside the loop instead)
>     f_scale = (f[-1] - f[0])/(f.shape[0]-1) if f.shape[0] > 1 else 1.0
>     t_scale = (t[-1] - t[0])/(t.shape[0]-1) if t.shape[0] > 1 else 1.0
>     #...
>     tr = QtGui.QTransform()
>     # Centre pixels on the data points
>     tr.translate(t[0] - t_scale/2, f[0] - f_scale/2)
>     tr.scale(t_scale, f_scale)
>     image = pg.ImageItem(specslice)
>     image.setTransform(tr)
>     plot.addItem(image)
>     spec_images.append(image)
>
> Patrick
> On Saturday, 18 September 2021 at 5:29:42 am UTC+9:30 
> [email protected] wrote:
>
>> Dear all,
>>
>> because matplotlib.pyplot is slow, I want to use pyqtgraph to display 
>> plots of scalar-valued functions of two variables. The figures I want to 
>> achieve are similar to contour plots or heat plots, in general they are 
>> false color displays of scalar-valued functions of two variables. In my 
>> special case they are parts of spectrogram data, which are combined to the 
>> plot of a whole spectrogram.
>>
>> My question is, if there is already a function or an object in pyqtgraph 
>> available, which is suitable to combine these parts of the spectrogram to a 
>> large spectrogram and show the result as an image? The axes should be 
>> suitably configurable and the position and the scale of the little 
>> spectrogram parts should also be choosable.
>>
>> I found a way to combine my little spectrogram parts using a 
>> GraphicsLayoutWidget, 
>> an ImageItem and translate and scale methods of the ImageItem object. 
>> This works fine besides the "DeprecationWarning: Deprecated Qt API, will be 
>> removed in 0.13.0.", which is shown because of the usage of the translate 
>> and scale methods.
>>
>> I wonder if there exists already another more simple way inside pqtgraph 
>> to show individual spectrogram parts as a whole spectrogram?
>>
>> An example is attached to the e-mail, which shows the principle of my 
>> ideas. There are shown individual images of sin-functions in y-direction 
>> and x-direction instead of spectrogram data to make the example easy.
>>
>> Do you have suggestions?
>> feli_x
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/cf7a8c71-eaba-414d-9409-08b30b33608fn%40googlegroups.com.

Reply via email to