Book Image

Interactive Applications using Matplotlib

Book Image

Interactive Applications using Matplotlib

Overview of this book

Table of Contents (12 chapters)

Matplotlib in your app


We have peered behind the canvas and have gained an immense understanding of how backends in Matplotlib operate. For four of the major backends, we have even seen how to augment our application with GUI widgets, learning some of the subtle differences in the backends.

But, what if you already have a GUI application written in Python, and the Matplotlib portion is the new feature to add? This is called embedding. The basic idea is that the canvas is added to your application as a widget. The tricky part is that you cannot let pyplot create the Figure instance. The pyplot module assumes that it will be responsible for triggering and terminating the application mainloop. It also automatically attaches the figure managers to the canvases. This can conflict with normal application operations. Therefore, when embedding, it is best to completely bypass pyplot.

Like in the previous section, we will examine how to embed the Matplotlib canvas into a GUI Python application in four...