GridItem — pyqtgraph 0.11.0rc0 documentation

# GridItem

class `pyqtgraph.` `GridItem`(pen='default', textPen='default')

  Bases: `UIGraphicsItem`

  Displays a rectangular grid of lines indicating major divisions within a coordinate system. Automatically determines what divisions to use.

  `__init__`(pen='default', textPen='default')

    Arguments: |
    bounds | QRectF with coordinates relative to view box. The default is QRectF(0,0,1,1), which means the item will have the same bounds as the view.

  `paint`(self, painter: PySide2.QtGui.QPainter, option: PySide2.QtWidgets.QStyleOptionGraphicsItem, widget: typing.Union[PySide2.QtWidgets.QWidget, NoneType] = None)
  `setPen`(*args, **kwargs)

    Set the pen used to draw the grid.

  `setTextPen`(*args, **kwargs)

    Set the pen used to draw the texts.

  `setTickSpacing`(x=None, y=None)

    Set the grid tick spacing to use.

    Tick spacing for each axis shall be specified as an array of descending values, one for each tick scale. When the value is set to None, grid line distance is chosen automatically for this particular level.

    Example:

      Default setting of 3 scales for each axis: setTickSpacing(x=[None, None, None], y=[None, None, None])

      Single scale with distance of 1.0 for X axis, Two automatic scales for Y axis: setTickSpacing(x=[1.0], y=[None, None])

      Single scale with distance of 1.0 for X axis, Two scales for Y axis, one with spacing of 1.0, other one automatic: setTickSpacing(x=[1.0], y=[1.0, None])

  `viewRangeChanged`()

    Called when the view widget/viewbox is resized/rescaled