【发布时间】:2019-12-16 15:20:26
【问题描述】:
有没有办法通过代码设置pyqtgraph ImageView X 和 Y 范围?通过在 GUI 程序中的 ImageView 上单击鼠标右键,可以选择设置 X 和 Y 轴。但是,在 ImageView 的 Docs API 参考中没有提及如何设置 X-Y 范围。
【问题讨论】:
有没有办法通过代码设置pyqtgraph ImageView X 和 Y 范围?通过在 GUI 程序中的 ImageView 上单击鼠标右键,可以选择设置 X 和 Y 轴。但是,在 ImageView 的 Docs API 参考中没有提及如何设置 X-Y 范围。
【问题讨论】:
我认为您正在寻找setLimits() 来限制视图范围。您可以使用xMin、xMax、yMin 和 yMax 设置 x 和 y 轴的最小/最大范围
plot_widget = pg.PlotWidget()
plot_widget.setLimits(xMin=1, xMax=5, yMin=0, yMax=100)
例如
plot_widget.setLimits(xMin=0, xMax=.5, yMin=0, yMax=400)
与
plot_widget.setLimits(xMin=.2, xMax=.3, yMin=0, yMax=125)
【讨论】:
感谢您的建议。我发现 ImageView 没有设置限制的选项。要为 ImageView 设置限制,必须将其用作 PlotItem,示例如下
self.plot = pg.PlotItem()
imv = pg.ImageView(self.plot)
现在可以使用 setLimits、setXRange、setYRange 或任何其他类似的函数来限制区域。
【讨论】: