【问题标题】:Set the X and Y range in pyqtgraph's ImageView在pyqtgraph的ImageView中设置X和Y范围
【发布时间】:2019-12-16 15:20:26
【问题描述】:

有没有办法通过代码设置pyqtgraph ImageView X 和 Y 范围?通过在 GUI 程序中的 ImageView 上单击鼠标右键,可以选择设置 X 和 Y 轴。但是,在 ImageView 的 Docs API 参考中没有提及如何设置 X-Y 范围。

【问题讨论】:

标签: python pyqtgraph


【解决方案1】:

我认为您正在寻找setLimits() 来限制视图范围。您可以使用xMinxMaxyMinyMax 设置 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)

【讨论】:

    【解决方案2】:

    感谢您的建议。我发现 ImageView 没有设置限制的选项。要为 ImageView 设置限制,必须将其用作 PlotItem,示例如下

    self.plot = pg.PlotItem()
    imv = pg.ImageView(self.plot)
    

    现在可以使用 setLimits、setXRange、setYRange 或任何其他类似的函数来限制区域。

    【讨论】:

      猜你喜欢
      • 2018-11-02
      • 2011-11-06
      • 2015-06-18
      • 1970-01-01
      • 1970-01-01
      • 2012-09-06
      • 1970-01-01
      • 2018-10-09
      • 1970-01-01
      相关资源
      最近更新 更多