首页 > 解决方案 > pyqtgraph custom grid [Python/Qt]

问题描述

I am trying to make my plot contain a grid with specific features like the grid lines separations, but I am not sure if pyqtgraph allows it. Anyone knows how to achieve this?

标签: python-3.xpyqtpyqtgraph

解决方案


The PlotItem class in pyqtgraph contains a showGrid function. For instance:

plot_example = pyqtgraph.plot(x_values, y_values)
plot_example.showGrid(True, True, 0.5)

By default, showGrid(x=None, y=None, alpha=None). first argument specifies whether or not to show x grid, second argument specifies whether or not to show the y grid, and alpha provides a variable opacity for the grid.

More info can be found here: http://www.pyqtgraph.org/documentation/_modules/pyqtgraph/graphicsItems/PlotItem/PlotItem.html#PlotItem.showGrid


推荐阅读