Hi,

What you describe should actually be the default behaviour when an 
ImageItem is placed in a plot when autoscale is enabled. If you have other 
items in the plot then they will affect the plot limits when autoscale is 
active, in which case you may want to set the position and scaling of the 
image to better match your "real world" plot units. The easiest is using 
the setRect() 
method:https://pyqtgraph.readthedocs.io/en/latest/graphicsItems/imageitem.html#pyqtgraph.ImageItem.setRect

If you'd like to restrict the plot zoom/pan limits so that the image always 
fills the view, then there are methods for the PlotItem (which get passed 
to the underlying ViewBox) to restrict scale, mouse interaction etc. Eg:

https://pyqtgraph.readthedocs.io/en/latest/graphicsItems/viewbox.html#pyqtgraph.ViewBox.setLimits
https://pyqtgraph.readthedocs.io/en/latest/graphicsItems/viewbox.html#pyqtgraph.ViewBox.setMouseEnabled
https://pyqtgraph.readthedocs.io/en/latest/graphicsItems/viewbox.html#pyqtgraph.ViewBox.autoRange

Patrick
On Monday, 22 August 2022 at 11:59:32 pm UTC+9:30 [email protected] wrote:

> This does not cut it, I am trying to use pytqgraph for this task, as I am 
> building this functionality as part of an GUI built in PyQt. My plan after 
> this is to edit some of the events to customize the behavior of the images.
>
> Thanks for the answer.
>
> El lunes, 22 de agosto de 2022 a las 16:12:23 UTC+2, 
> [email protected] escribió:
>
>> Le 22/08/2022 à 15:47, Oier Arcelus a écrit :
>>
>> I have an image to be shown using pyqtgraph. For this I use a numpy 2D 
>> array, which has a many elements along axis 1, but less along axis 0. As a 
>> result, I obtain ImageView's with very high aspect ratio, and I would like 
>> to stretch it such that it fits to the original view of the window that its 
>> shown in the screen.
>>
>> I cannot find any entries about this in the forum and any help about this 
>> would be greatly appreaciated.
>>
>> Use (e.g.) PIL (Pillow...) and numpy, say:
>>
>>
>>
>>
>>
>>
>>
>>
>> *from PIL import Image import numpy as np img = 
>> Image.open('yourimage.png') nimg = img.resize((200, 100))  # for example 
>> nimg.show() # or not. tbl=np.array(nimg)*
>>
>> This is all. Unless I misunderstood your problem. Do you need some 
>> specific interpolation policy? You don't even say what is the colour depth 
>> of your image, so I chose anything...
>>
>> Jerzy Karczmarczuk
>>
>>
>>
>> [image: width=] 
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
>>  Sans 
>> virus.www.avast.com 
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
>>  
>> <#m_-6707021876982350282_m_-7460269599118137348_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>

-- 
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/78857768-f6a0-4fcc-a4ff-af1bd0c508d4n%40googlegroups.com.

Reply via email to