Skip to main content

A figure page creator class

Project description

Code style: black GitHub Workflow Status PyPI version PyPI pyversions License: MIT

figpager

Matplotlib is a graphics library for Python that can save plots with various backends and single or multiple pages. FigPager is a wrapper class for those backends.

FigPager is similar to other third party Matplotlib packages that allow figure elements to be added such as a title block, border and logo. One example package is mpl-template.

The FigPager class reads layout specifications from an .ini file. FigPager handles drawing boxes, text, images and lines referenced in .ini files on a figure canvas. The class handles adding subplots, adding new pages in multipage backends and closing the figure.

Example output from tests\test_1.py

Install

Install using pip. figpager has been tested for Python 2.7, Python 3.7 and Python 3.8. See requirements.txt for dependencies.

pip install figpager

Usage

After install FigPager can be imported from figpager.

from figpager import FigPager

A FigPager instance is initialized with a paper size of A0-A10, B0-B10, letter, legal or ledger, the number of plot panels in a row as an integer and the number of plot panels as columns as an integer. 3 rows and 3 columns of panels for a figure of 3x3 is depicted below.

fp = FigPager(
        "letter",
        3,
        3,
    )

Additional keywords provide further functionality. See the code for all keywords.

fp = FigPager(
        "letter",
        3,
        2,
        layout="Report",
        outfile=.\out.pdf,
        orientation="portrait",
        height_ratios=[1, 1, 2],
        overwrite=True,
        transparent=True,
    )

with blocks are also supported with no need for fp.close()

with FigPager("letter", 3, 2, layout="Report", outfile=.\out.pdf,
        orientation="portrait", height_ratios=[1, 1, 2],
        overwrite=True, transparent=True) as fp:

Example layout .ini files can be found in the package under page_layout.

FigPager has options to add subplots. See the code for all keywords.

ax0 = fp.add_subplot()

FigPager also has add page options. In backends that don't support multipage a zero padded number is added as a suffix to the file name.

The example below specifies the number of rows and columns, the orientation and height ratios. See the code for all keywords.

fp.add_page(
                nrows=3, ncols=2, orientation="portrait", height_ratios=[1, 1, 2]
           )

FigPager options read from an .ini file can be updated via the instance's config. The syntax is config[section][subsection][option] = value.

fp.config['Text']['Document Title']['text']

Finally, FigPager instance can be closed following the example below.

fp.close()

See the test code under tests for example code.

Development / Testing

Submit issues and PRs through GitHub. Testing is done with tox. pytest, black and isort are run against code.

License

figpager is released under the MIT license. See LICENSE.md for details.

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

figpager-0.32.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

figpager-0.32-py2.py3-none-any.whl (16.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file figpager-0.32.tar.gz.

File metadata

  • Download URL: figpager-0.32.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for figpager-0.32.tar.gz
Algorithm Hash digest
SHA256 f1679f26f6fe6f42df0bb2379c42d6bb41683263a38bc90cece8b95879d42453
MD5 e01379b12e9aa3339cfba05a206cdfee
BLAKE2b-256 e9b6c3f53c0088156c2025f4c3c2f248e031c2379e9081f42bb0c827d9bc5c5e

See more details on using hashes here.

File details

Details for the file figpager-0.32-py2.py3-none-any.whl.

File metadata

  • Download URL: figpager-0.32-py2.py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for figpager-0.32-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b3aae3c21b75ce4b295954eafcebf8b191eb88fc93f2bd884df0777707c40aef
MD5 629bba3b749c110f589d036f7277ba59
BLAKE2b-256 318a99083df6fd04504f3b0f6c006cd04de0a30716f60bcf2b0fcb1948ea04fc

See more details on using hashes here.

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