O'Reilly logo

Matplotlib for Python Developers by Sandro Tosi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Embedding a Matplotlib figure in a GTK+ window

We can now start to describe how to embed a Matplotlib Figure into a GTK+ window as we walk through the code. We will present a simple example, and describe it step-by-step, highlighting the important parts of the code, in particular the GTK+ related ones.

Note again, we are not going to explain the GTK+ functionalities completely, and it is left to the reader to read further if he/she is interested.

Let's start:

import gtk
from matplotlib.figure import Figure
import numpy as np

These are the usual imports along with the gtk module, which is required to access the GTK+ library functions. Once imported, the gtk module also takes care of GTK+ environment initialization.

It is also common to find this type ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required