Skip to main content

Format Matplotlib for scientific plotting

Project description

Science Plots

Warning : As of version 2.0.0, you need to add import scienceplots before setting the style (plt.style.use('science')).

PyPI version DOI

Matplotlib styles for scientific figures

This repo has Matplotlib styles to format your figures for scientific papers, presentations and theses.

You can find the full gallery of included styles here.

Getting Started

The easiest way to install SciencePlots is by using pip:

# to install the lastest release (from PyPI)
pip install SciencePlots

# to install the latest commit (from GitHub)
pip install git+https://github.com/garrettj403/SciencePlots

# to clone and install from a local copy
git clone https://github.com/garrettj403/SciencePlots.git
cd SciencePlots
pip install -e .

From version v1.1.0 on, import scienceplots is needed on top of your scripts so Matplotlib can make use of the styles.

Notes:

Please see the FAQ for more information and troubleshooting.

Using the Styles

"science" is the primary style in this repo. Whenever you want to use it, simply add the following to the top of your python script:

import matplotlib.pyplot as plt
import scienceplots

plt.style.use('science')

You can also combine multiple styles together by:

plt.style.use(['science','ieee'])

In this case, the ieee style will override some of the parameters from the science style in order to configure the plot for IEEE papers (column width, fontsizes, etc.).

To use any of the styles temporarily, you can use:

with plt.style.context('science'):
    plt.figure()
    plt.plot(x, y)
    plt.show()

Examples

The basic science style is shown below:

It can be cascaded with other styles to fine-tune the appearance. For example, the science + notebook styles (intended for Jupyter notebooks):

Please see the project Wiki for a full list of available styles.

Specific Styles for Academic Journals

The science + ieee styles for IEEE papers:

  • IEEE requires figures to be readable when printed in black and white. The ieee style also sets the figure width to fit within one column of an IEEE paper.

The science + nature styles for Nature articles:

  • Nature recommends sans-serif fonts.

Other languages

SciencePlots currently supports:

Example: Traditional Chinese (science + no-latex + cjk-tc-font):

See the FAQ for information on installing CJK fonts.

Other color cycles

SciencePlots comes with a variety of different color cycles. For a full list, see the project Wiki. Two examples are shown below.

The bright color cycle (color blind safe):

The high-vis color cycle:

Help and Contributing

Please feel free to contribute to the SciencePlots repo! For example, it would be good to add new styles for different journals and add new color cycles. Before starting a new style or making any changes, please create an issue through the GitHub issue tracker. That way we can discuss if the changes are necessary and the best approach.

If you need any help with SciencePlots, please first check the FAQ and search through the previous GitHub issues. If you can't find an answer, create a new issue through the GitHub issue tracker.

You can checkout Matplotlib's documentation for more information on plotting settings.

FAQ

You can find the FAQ in the project Wiki.

SciencePlots in Academic Papers

The following papers use SciencePlots:

If you use SciencePlots in your paper/thesis, feel free to add it to the list!

Citing SciencePlots

You don't have to cite SciencePlots if you use it but it's nice if you do:

@article{SciencePlots,
  author       = {John D. Garrett},
  title        = {{garrettj403/SciencePlots}},
  month        = sep,
  year         = 2021,
  publisher    = {Zenodo},
  version      = {1.0.9},
  doi          = {10.5281/zenodo.4106649},
  url          = {http://doi.org/10.5281/zenodo.4106649}
}

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

SciencePlots-2.0.1.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

SciencePlots-2.0.1-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file SciencePlots-2.0.1.tar.gz.

File metadata

  • Download URL: SciencePlots-2.0.1.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for SciencePlots-2.0.1.tar.gz
Algorithm Hash digest
SHA256 efee11d664029e2da1c634addd961972633d16a2d9a30b64331b10ee6c8ba2f0
MD5 81238bcd7ec584463cf8121b1ab622e9
BLAKE2b-256 a0b7f696584cda548b0483aae1fa0316c8ab833df055d8dfd3d3fc430dc376f9

See more details on using hashes here.

File details

Details for the file SciencePlots-2.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for SciencePlots-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a85ea9083b2b0cea0a96478d2f1840873bca0c4228fe4eb7e866fb1a68ce1d46
MD5 3995f772b231d0a6e59230129cce7255
BLAKE2b-256 c808694381daaa7002621bd0232de803b2f58069cecd968a1e2f2dd8b47f3bac

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