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 wxFrame

We will present examples by commenting each relevant source code block, and at the end, we will show the complete source code.

In the first example, we will describe how to embed a Matplotlib Figure in a wxFrame.

wxFrame is one of the most important widgets in wxWidgets. It's considered to be a container because it contains other widgets. wxFrame consists of a title bar, borders, and a center container area: the classic application window layout.

The example code starts with:

import wx

This is the main wxPython module. It contains all the submodules, objects, and functions for the wxWidgets library. Every application that uses wxPython imports this module.

from matplotlib.figure import Figure import numpy ...

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