[Python] Moving from matplotlib to pyqtgraph: how to reuse PlotWidgets?

Discussão em 'Python' iniciado por Stack, Julho 23, 2025.

  1. Stack

    Stack Membro Participativo

    I have a large gui app based on matplotlib which is horribly slow (on windows) so I am trying to re-host it on pyqtgraph (which seems to be much faster).

    I am facing the following problem: I need to plot very different things (vastly different ranges, axes formatting &c: e.g., sometimes X is $$ from 0 to 1B and sometimes X is time from midnight to now, and sometimes date from last year to now) in the same screen area.

    With matplotlib I re-use the same Axes object (pre-inserted in the subplot2grid), because after ax.clear() it is as new and I can set axis formatters and the ax.plot sets xlim and ylim correctly.

    With pyqtgraph re-using is much harder because I cannot reset axisItems in a PlotWidget, and pw.clear() does not remove title, axis labels, grids, ticks.

    Should I create a new PlotWidget for each plot type and replace it in the layout?

    Continue reading...

Compartilhe esta Página