【问题标题】:Is there a way to hide the x and y axis when using the ScatterPlotItem and PlotCurveItem使用 ScatterPlotItem 和 PlotCurveItem 时有没有办法隐藏 x 和 y 轴
【发布时间】:2019-11-23 14:37:46
【问题描述】:

我正在使用 pyqtgraph 绘制一个二维 numpy 数组。我想绘制没有 x 或 y 轴的数据。目前我的情节是这样的

但我不想要 x 或 y 轴。我希望有这样的东西

我绘制的方式是创建一个 PlotWidget 对象并将其添加到我的主窗口。在用户加载该数据后,我创建了一个 ScatterPlotItem 和 PlotCurveItem 并将其添加到 PlotWidget。

我尝试阅读 PlotWidget、ScatterPlotItem 和 PlotCurveItem 的文档,但我并没有真正找到隐藏轴的方法。

我想知道是否有一种方法可以只绘制没有 x,y 轴的点和线?

【问题讨论】:

    标签: python pyqtgraph


    【解决方案1】:

    PlotItem.hideAxis()

    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()
    

    结果:

    【讨论】:

      猜你喜欢
      • 2020-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多