Is there any way to set the pyqtgraph ImageView X and Y range by code? By clicking right mouse button on ImageView in GUI program, there is an option to set the X and Y axis. However, in the Docs API Reference for ImageView there is no mention of how to set the X-Y range.
Asked
Active
Viewed 2,333 times
1
-
This might help you: https://stackoverflow.com/questions/29598442/python-pyqtgraph-how-to-set-x-and-y-axis-limits-on-graph-no-autorange – Michael Kolber Aug 08 '19 at 21:44
2 Answers
1
I think you're looking for setLimits()
to constrain the view range. You can set the minimum/maximum range for the x and y axis using xMin
, xMax
, yMin
, and yMax
plot_widget = pg.PlotWidget()
plot_widget.setLimits(xMin=1, xMax=5, yMin=0, yMax=100)
For instance with
plot_widget.setLimits(xMin=0, xMax=.5, yMin=0, yMax=400)
and with
plot_widget.setLimits(xMin=.2, xMax=.3, yMin=0, yMax=125)

nathancy
- 42,661
- 14
- 115
- 137
0
Thank you for advices. I found that ImageView doesn't have an option to set limits. To set limits for ImageView, it must be uses as PlotItem, example below
self.plot = pg.PlotItem()
imv = pg.ImageView(self.plot)
and now its possible to use setLimits, setXRange, setYRange or any other similar function to limit region.

Arturas Aleksandrovas
- 119
- 5