使用 ScatterPlotItem 和 PlotCurveItem 时有没有办法隐藏 x 轴和 y 轴
Is there a way to hide the x and y axis when using the ScatterPlotItem and PlotCurveItem
我正在使用 pyqtgraph 绘制二维 numpy 数组。我想在没有 x 或 y 轴的情况下绘制我的数据。目前我的情节是这样的
但我不想要 x 或 y 轴。我希望有这样的东西
我的绘图方式是创建一个 PlotWidget 对象并将其添加到我的主 window。在用户加载该数据后,我创建了一个 ScatterPlotItem 和 PlotCurveItem 并将其添加到 PlotWidget。
我尝试阅读 PlotWidget、ScatterPlotItem 和 PlotCurveItem 的文档,但我并没有真正找到隐藏轴的方法。
我想知道是否有一种方法可以在没有 x,y 轴的情况下只绘制点和线?
import pyqtgraph as pg
import numpy as np
app = pg.mkQApp()
x = np.random.rand(10,)
y = np.random.rand(10,)
w = pg.PlotWidget()
c = pg.PlotCurveItem(x,y)
s = pg.ScatterPlotItem(x,y)
w.addItem(c)
w.addItem(s)
w.getPlotItem().hideAxis('bottom')
w.getPlotItem().hideAxis('left')
w.show()
app.exec()
结果:
我正在使用 pyqtgraph 绘制二维 numpy 数组。我想在没有 x 或 y 轴的情况下绘制我的数据。目前我的情节是这样的
但我不想要 x 或 y 轴。我希望有这样的东西
我的绘图方式是创建一个 PlotWidget 对象并将其添加到我的主 window。在用户加载该数据后,我创建了一个 ScatterPlotItem 和 PlotCurveItem 并将其添加到 PlotWidget。
我尝试阅读 PlotWidget、ScatterPlotItem 和 PlotCurveItem 的文档,但我并没有真正找到隐藏轴的方法。
我想知道是否有一种方法可以在没有 x,y 轴的情况下只绘制点和线?
import pyqtgraph as pg
import numpy as np
app = pg.mkQApp()
x = np.random.rand(10,)
y = np.random.rand(10,)
w = pg.PlotWidget()
c = pg.PlotCurveItem(x,y)
s = pg.ScatterPlotItem(x,y)
w.addItem(c)
w.addItem(s)
w.getPlotItem().hideAxis('bottom')
w.getPlotItem().hideAxis('left')
w.show()
app.exec()
结果: