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 Tableau classic 10 color scheme which looks less saturated and more pleasing to eyes. Other available color schemes for multi-line plots are ColorBrewer Set 1 and Tableau classic 20. For more information on these color schemes, see documentation of palettable.

mpltex also provide a way to generate highly configurable line styles with colors, line types, and line markers. Hollow markers are supported.

Quickstart

1. Install

$ pip install mpltex

Required Packages

  • matplotlib. Can be installed via pip install matplotlib.

  • palettable. Can be installed via pip install palettable.

2. Usage

Examples and sample plots can be found here.

To use mpltex, just add one of mpltex decorators before your plot functions.

import mpltex

@mpltex.acs_decorator
def myplot():
    # 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.
myplot()

And it will create a plot ready for publishing in journals published by American Chemical Society (ACS).

Available Decorators

  • mpltex.acs_decorator: output EPS images for publishing in ACS (American Chemical Society).

  • mpltex.aps_decorator: output EPS images for publishing in APS (American Physical Society).

  • mpltex.rsc_decorator: output EPS images for publishing in RSC (Royal Society of Chemistry).

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

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

mpltex also provides several helper functions to facilitate production of specific type of images. Following codes will produce a set of line arts with cycled line styles with the help of mpltex.linestyle_generator function. Note that since version 0.5, linestyles is a shorthand for linestyle_generator.

import matplotlib.pyplot as plt
import mpltex

@mpltex.acs_decorator
def myplot():
    # ...   # generate data x and y
    fig, ax = plt.subplots(111)

    # The default line style is iterating over
    # color, line, and marker with hollow types.
    linestyles = mpltex.linestyles()
    # equivalently
    # linestyles = mpltex.linestyle_generator()

    for i in range(number_of_lines):
        ax.plot(x[i], y[i], label=str(i), **next(linestyles)

    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')

Contribute

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.6.1.tar.gz (10.3 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: mpltex-0.6.1.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for mpltex-0.6.1.tar.gz
Algorithm Hash digest
SHA256 aa04ce34d3ca5478fdfd0665a77f0f7a64b37cdaf9416fab0c7c8e04637d0823
MD5 784d57ed6a0a2b1ac0956151dd83b07b
BLAKE2b-256 e089bff48f5114fe8c657ca59a4471f4f4fa473ae4c1170fb20f4650c8949be4

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