Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Renderer to expose matplotlib figures

Project Description

About tgext.matplotrender

tgext.matplotrender is a TurboGears2 extension that provides a Rendering Engine for MatplotLib Figures.


tgext.matplotrender can be installed from pypi:

pip install tgext.matplotrender

should just work for most of the users.


To enable tgext.matplotrender add the matplotfig renderer to your configuration:


and plug the rendering engine inside your config/

import tgext.matplotrender


Using tgext.matplotrender is as simple as exposing an action with the matplotfig template and returning the figure itself inside the fig key of action returned dictionary.

Given the following figure:

def _make_fig():
    fig = matplotlib.figure.Figure(figsize=(9, 6))
    fig.Name = "Sinewave"
    ax = fig.add_subplot(111)
    t = numpy.arange(0.0, 2.0, 0.01)
    s1 = numpy.sin(2 * numpy.pi * t)
    ax.plot(t, s1, color="k")
    return fig

It can be exposed through TurboGears actions as:

class RootController(TGController):
    def figure(self, *args, **kwargs):
        return dict(fig=_make_fig())

    @expose('matplotfig', render_params=dict(dpi=36))
    def lowres(self, *args, **kwargs):
        return dict(fig=_make_fig())

    def customres(self, *args, **kwargs):
        options = {}
            options['dpi'] = int(kwargs['dpi'])
        return dict(fig=_make_fig(), **options)

Any other value provided in the dictionary will be used as a print_figure argument in matplotlib

Release History

Release History

This version
History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
tgext.matplotrender-0.0.1.tar.gz (3.3 kB) Copy SHA256 Checksum SHA256 Source Jun 6, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting