Python pyqtgraph how to set x and y axis limits on graph, no autorange

后端 未结 3 1165
-上瘾入骨i
-上瘾入骨i 2021-02-20 11:31

I would like to know how I can set the x and y axis limits that are displayed for a pyqtgraph.GraphicsWindow.addPlot object. I need to display a lot of data inside a loop (hence

相关标签:
3条回答
  • 2021-02-20 11:57

    The questions asks how to set a limit to the view which none of the responses to this point answers. For others who come across this the view of the plot can be limited to a section of the axis like this:

    p1.plotItem.vb.setLimits(xMin=a, xMax=b, yMin=c, yMax=d)
    

    Documentation: http://www.pyqtgraph.org/documentation/graphicsItems/viewbox.html

    0 讨论(0)
  • 2021-02-20 12:07

    As the error message indicates, you have not supplied the correct number of arguments to setXRange(). The correct line should look like:

    p1.setXRange(5, 20, padding=0)
    

    Documentation here: http://www.pyqtgraph.org/documentation/graphicsItems/viewbox.html#pyqtgraph.ViewBox.setXRange

    0 讨论(0)
  • 2021-02-20 12:08

    Michael.

    The easiest way would be to simply specify your ranges as elements of a list. Replace the p1.setXRange with something like this:

    p1.setRange(xRange=[5,20])
    

    And that's it!

    Check the documentation of this class in: http://www.pyqtgraph.org/documentation/graphicsItems/viewbox.html#pyqtgraph.ViewBox.setRange

    0 讨论(0)
提交回复
热议问题