Skip to main content

mpl-template: matplotlib report template constructor

Project description

mpl-template

A python class for creating full report figures, including borders, titleblocks, logos, and content, entirely within matplotlib.

Build Status codecov

Sphinx Docs

Quick start

Simply importing mpl_template lets you use the report template module.

import matplotlib as mpl
from mpl_template import template
import math

report_fig = template.Template(figsize=(8.5, 11), draft=True, scriptname='template.py')

title_block = [
    {
        'name': 'title',
        'text': {
            's': 'Example Figure',
            'x': 0.5,
            'y': 0.5,
            'va': 'center',
            'ha': 'center',
        }
    },
    {},{},{},{},
]
report_fig.titleblock_content = title_block
report_fig.path_text = 'template.py'
fig = report_fig.setup_figure()
page_ax = report_fig.add_page()

# create a sub-gridspec that will be used for the main image
left, right, top, bottom = report_fig.margins
main = report_fig.gsfig[4 + top:-(report_fig.t_h + bottom + 8), 8 + left:-(right + 8)]
gs_timeseries = mpl.gridspec.GridSpecFromSubplotSpec(3, 1, main, hspace=0.3, wspace=0.3)

for n in range(3):
    ax = fig.add_subplot(gs_timeseries[n])
    ax.set_ylim(-2.5, 2.5)
    plot = ax.plot([math.sin(i * (n + 1)) for i in range(0, 100)])

Alt text

Installation

Dependencies

requires: matplotlib optional: pillow, requests tests: pytest, pytest-mpl

Official Releases

TODO: release on pypi For now, please install from source.

Development Builds

This is a pure-python package, so building from source is easy on all platforms:

git clone https://github.com/austinorr/mpl-template.git
cd mpl-template
pip install -e .

Testing

Testing is done via pytest: $pytest --mpl

Project details


Download files

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

Source Distribution

mpl_template-0.3.1.tar.gz (2.6 MB view details)

Uploaded Source

File details

Details for the file mpl_template-0.3.1.tar.gz.

File metadata

  • Download URL: mpl_template-0.3.1.tar.gz
  • Upload date:
  • Size: 2.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for mpl_template-0.3.1.tar.gz
Algorithm Hash digest
SHA256 4428d4359506804f3f6f7d178ab9f33be7efa7656ea2e8bcf0f71eaee42fbc91
MD5 d396c5aaa15da5f8457d8341a51c2c7e
BLAKE2b-256 25a438c727fb0a5bff1a01282084825e5847c243be69bf0c676f2883a553786a

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page