About tgext.matplotrender
tgext.matplotrender is a TurboGears2 extension that provides a Rendering Engine for MatplotLib Figures.
Installing
tgext.matplotrender can be installed from pypi:
pip install tgext.matplotrender
should just work for most of the users.
Enabling
To enable tgext.matplotrender add the matplotfig renderer to your configuration:
base_config.renderers.append('matplotfig')
and plug the rendering engine inside your config/app_cfg.py:
import tgext.matplotrender
tgext.matplotrender.plugme(base_config)
Usage
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)
ax.set_xlabel("angle")
ax.set_ylabel("amplitude")
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):
@expose('matplotfig')
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())
@expose('matplotfig')
def customres(self, *args, **kwargs):
options = {}
try:
options['dpi'] = int(kwargs['dpi'])
except:
pass
return dict(fig=_make_fig(), **options)
Any other value provided in the dictionary will be used as a print_figure argument in matplotlib
Metadata
Release files for tgext.matplotrender 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tgext.matplotrender-0.0.1.tar.gz | 3.3 kB | Without provenance | Details for tgext.matplotrender-0.0.1.tar.gz |
Release files / tgext.matplotrender-0.0.1.tar.gz
| Download URL | tgext.matplotrender-0.0.1.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6defa801397021524e25f9b59ed028b61e051f238a8dd5d343569254a97ec67f
|
|
BLAKE2b-256 checksum How to use checksums |
a25983b6a484ee7fa8e75a1213184e8d44b1892813e6ef27643736ececf7e737
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for tgext.matplotrender 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.