Book Image

matplotlib Plotting Cookbook

By : Alexandre Devert
Book Image

matplotlib Plotting Cookbook

By: Alexandre Devert

Overview of this book

Table of Contents (15 chapters)
matplotlib Plotting Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Integrating a plot in a Pyglet application


Pyglet is a very well written Python module to use OpenGL on any platform. Using Pyglet (and thus OpenGL) allows you to use the graphic hardware of your computer to its maximum. For instance, it would be fairly easy with Pyglet to show figures on three adjacent screens with fancy transition effects. In this recipe, we are going to see how to interface matplotlib with Pyglet. As in the previous example, we are going to display the SuperShape curve on the full screen and without any widgets.

How to do it...

Pyglet does not have the same functionality with widgets as Tkinter and wxWidgets have. This script will render a curve to an in-memory image. That image will then be simply shown on the whole screen surface. Thus, the figure will be shown on a full screen mode. Let's see how this is done using the following code:

import pyglet, StringIO
import numpy as np

from matplotlib.figure import Figure
from matplotlib.backends.backend_agg import FigureCanvasAgg...