In this case you make the matplotlib figure take up the entire window, replacing the central widget. This means you cannot use QtDesigner to add UI controls and would have to do it all by hand.
Is there any way to embed just the axes in a Qt widget such as GraphicsView? While matplotlib figures are designed to use the whole window, a single axis could just use one widget. You can do this with pyqtgraph ( a diffent plotting library), but I’m not sure if its possible with matplotlib.
@Patrick_Raphael the matplotlib canvas is just a normal QWidget onto which the plot is drawn. That means you can do anything with it you can with a normal widget.
If you would like to build your UI in Qt Designer you have two options –
- Use “promote” to place a matplotlib widget (based on a QWidget) in Qt Designer this tutorial for embedding PyQtGraph will explain how (the process isn’t PyQtGraph specific)
- Build your layout except for the plot in Qt Designer and then place just that from your code
Using Qt Designer doesn’t prevent you from also writing normal layout code, it just pre-generates a bunch for you.
Does that help?