Skip to main content

mpltex is a python package for creating publication-quality plots using matplotlib.

Project description

mpltex is a python package for producing publication quality images using matplotlib. Inspired by Olga Botvinnik’s python package prettyplotlib.

The internal matplotlib color cycle is replaced by ColorBrewer Set1 scale which looks less saturated and more pleasing to eyes. For more information on ColorBrewer, see a flash-based interactive map and a quick visual reference to all ColorBrewer scales.

mpltex also enable cycle line styles and a selected set of line markers. Hollow markers are supported.

Quickstart

1. Install

$ pip install mpltex

Required Packages

  • matplotlib. Can be installed via pip install matplotlib.

  • brewer2mpl. Can be installed via pip install brewer2mpl.

2. Usage

Just add one of mpltex decorators before your plot functions.

import mpltex

@mpltex.acs_decorator
def your_plot():
    # plot images by matplotlib ...

    # Save the image. Give a file name without extension.
    # You can also save figure outside your_plot if you like.
    fig.save_fig('/path/to/save/fig/figname')

# Then use your_plot in a normal way.
your_plot()

And it will produce images suitable for publishing in American Chemical Society (ACS).

mpltex also contains several helper functions to faciliate production of specific type of images. Following codes will produce a set of line arts with cycled line styles and line markers with the help of mpltex.linestyle_generator function.

import matplotlib.pyplot as plt
import mpltex

@mpltex.acs_decorator
def your_plot():
    # generate data x and y
    fig, ax = plt.subplots(111)
    for i in range(number_of_lines):
        # The default line style is iterating over
        # color, line, and marker with hollow types.
        linestyles = mpltex.linestyle_generator()
        ax.plot(x[i], y[i], label=str(i), **linestyles.next())

    ax.locator_params(nbins=5)  # limit the number of major ticks
    ax.legend(loc='best')  # show legend in a best location
    fig.tight_layout(pad=0.1)  # make layout as tight as possible
    fig.savefig('/path/to/save/fig/figname')

Available Decorators

  • mpltex.acs_decorator: output EPS images for publishing in ACS.

  • mpltex.presentation_decorator: output PDF images for presentation slides (Keynote).

  • mpltex.web_decorator: output PNG images for web pages.

Examples and sample plots can be found here.

Contribute

Let me know what you think and wish. I can be reached through email or other ways. Or fork the project at github.com and file a pull request.

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

mpltex-0.2.2.tar.gz (8.8 kB view details)

Uploaded Source

File details

Details for the file mpltex-0.2.2.tar.gz.

File metadata

  • Download URL: mpltex-0.2.2.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mpltex-0.2.2.tar.gz
Algorithm Hash digest
SHA256 eb26a4f7ae5695d166285c9bfdc0c3499feafc962143d62f1f705bf759e85118
MD5 29e37db227e2d15ebeaa8a3ab326371c
BLAKE2b-256 5a828f0e6e48ae871d438d0934bde07fc48c5ad505d8be392ed4fb6ec126fd9d

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