Skip to main content

mpltex is a python package for producing publication quality images using matplotlib.

Project description

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

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_decorators
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 includes several helper functions to faciliate production of specific type of images. Following code will produce a set of line arts with cycled line styles and line markers

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

    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.

Contribute

Please do not hesitate to submit your own configurations. I will add them to the package.

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

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for mpltex-0.1.tar.gz
Algorithm Hash digest
SHA256 30349ae2f9d1afde960e412af57e5a0f4b0eaf9fcff7f94eed377e76cf5f89be
MD5 59f6160db086570ecb639ea493ae6950
BLAKE2b-256 a5401e3fded1402aaf49894689735815600d0918ca0e40d4f2d743ac5222365a

See more details on using hashes here.

Supported by

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