Skip to main content

Science Plots

PyPI version DOI

Matplotlib styles for scientific figures

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

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 then install from a local copy
git clone https://github.com/garrettj403/SciencePlots.git
cd SciencePlots
pip install -e .

The pip installation will automatically move all of the Matplotlib style files *.mplstyle into the appropriate directory on your computer.

Notes:

Please see the FAQ section for more information and troubleshooting.

Using the Styles

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

import matplotlib.pyplot as plt

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', 'ieee']):
    plt.figure()
    plt.plot(x, y)
    plt.show()

Examples

The science style:

The science + grid styles:

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.

The science + scatter styles for scatter plots:

The science + notebook styles for Jupyter notebooks:

You can also combine these styles with the other styles that come with Matplotlib. For example, the dark_background + science + high-vis styles:

Note: See the examples/ directory for more!

CJK Fonts

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

Simplified Chinese (science + no-latex + cjk-sc-font):

Japanese (science + no-latex + cjk-jp-font):

Korean (science + no-latex + cjk-kr-font):

See the FAQ for information on installing CJK fonts.

Color Blind Safe Color Cycles

The bright color cycle (7 colors):

The vibrant color cycle (7 colors):

The muted color cycle (10 colors):

The high-contrast color cycle (3 colors):

The light color cycle (9 colors):

Note: These color cycles are from Paul Tol's website.

Other Color Cycles

The std-colors color cycle (used to override other color cycles, e.g., the color cycle from ieee):

The high-vis color cycle:

The retro 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

  1. Installing Latex:

  2. Installing CJK fonts

    • To use Chinese, Japanese or Korean fonts, you first need to install Noto CJK Fonts. You can download and install these fonts from the given link or you can install them with a package manager:

      # Ubuntu / Debian
      sudo apt update
      sudo apt install fonts-noto-cjk
      
      # macOS
      brew tap homebrew/cask-fonts
      brew cask install font-noto-serif-cjk-tc
      brew cask install font-noto-serif-cjk-sc
      brew cask install font-noto-serif-cjk-jp
      brew cask install font-noto-serif-cjk-kr
      
      # archlinux
      sudo pacman -S noto-fonts-cjk
      
    • For Windows Subsystem for Linux (WSL), you will need to manually download and install the fonts by following these instructions.

    • Note that matplotlib may not find the fonts correctly. You can refresh the font cache by running:

      import matplotlib.font_manager as fm
      fm._rebuild()
      
    • See this issue for more information.

  3. Installing SciencePlots manually:

    • If you like, you can install the *.mplstyle files manually. First, clone the repository and then copy all of the *.mplstyle files into your Matplotlib style directory. If you're not sure where this is, in an interactive python console type:

      import matplotlib
      print(matplotlib.get_configdir())
      
    • You should get back something like /home/garrett/.matplotlib. You would then put the *.mplstyle files in /home/garrett/.matplotlib/stylelib/ (you may need to create the stylelib directory):

      cp styles/*/*.mplstyle ~/.matplotlib/stylelib/
      
  4. Using different fonts:

    • SciencePlots uses the default serif font. If you would like to specify a different font, you can use:

      import matplotlib.pyplot as plt 
      plt.style.use('science')
      plt.rcParams.update({
          "font.family": "serif",   # specify font family here
          "font.serif": ["Times"],  # specify font here
          "font.size":11})          # specify font size here
      
    • If you would like to use Times New Roman specifically, please see the discussion in this issue.

  5. Installing SciencePlots within Google Colab, IPython, Jupyter Notebooks, etc.:

    • After installing SciencePlots within one of these environments, you may need to reload the Matplotlib style library. For example:

      !pip install SciencePlots
      import matplotlib.pyplot as plt
      plt.style.reload_library()
      plt.style.use('science')
      

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}
}

Metadata

Release files for SciencePlots 1.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for SciencePlots 1.0.9
File Size Uploaded Provenance Actions
SciencePlots-1.0.9.tar.gz 10.8 kB Without provenance Details for SciencePlots-1.0.9.tar.gz

Release files / SciencePlots-1.0.9.tar.gz

Download URL SciencePlots-1.0.9.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2b002f263734a718acdf1e5be57f0de5ee887e70517dfbe1118a27d0ee3dfb0f
BLAKE2b-256 checksum
How to use checksums
c2447b5c0ecd6f2862671a076425546f86ac540bc48c1a618a82d6faa3b26f58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/3.7.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.11

Security for SciencePlots 1.0.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page