Skip to content

Matplotlib styles for scientific plotting adhering to the STFC style guide

License

Notifications You must be signed in to change notification settings

georgeholt1/STFCSciencePlots

 
 

Repository files navigation

STFC Science Plots

Matplotlib styles for scientific figures using STFC style

This repo has Matplotlib styles to format your figures for scientific papers, presentations and theses following the Science and Technology Facilities Council (STFC) style. It is a fork of garrettj403's SciencePlots.

Getting Started

The easiest way to install STFCSciencePlots is by using pip:

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

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

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

Notes:

The SciencePlots FAQ may be useful for more information and troubleshooting.

Using the Styles

"stfc" 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

plt.style.use('stfc')

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

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

Using the Function Replacements

Some functions designed to replace Matplotlib methods are also contained in this library. Their usage is documented in their docstrings. Typically, a matplotlib object must be passed as an argument, and keyword arguments to be forwarded to the matplotlib function call are supplied in a keyword argument dictionary. For example, to use the legend replacement function:

# Import as usual
from stfcscienceplots import legend as stfclegend
plt.style.use('stfc')

# Load/generate/whatever some data
x = # data
y = # data

# Plot using the OOP API
fig, ax = plt.subplots()
ax.plot(x, y, label='data')

# Instead of calling ax.legend():
stfclegend(ax, legend_kwargs={'title': 'Legend'})

Examples

See examples/plot_examples.py.

About

Matplotlib styles for scientific plotting adhering to the STFC style guide

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%