Skip to content
spalatoPublic

About

Matplotlib stylesheets and figure design tools.

Resources

Stars

5 stars

Watchers

1 watching

Forks

Latest commit

 

History

22 Commits

Folders and files

Repository files navigation

scistyles

Matplotlib stylesheets for scientific publications.

Installation

The package is available on pypi. Simply run:

pip install scistyles

Usage

The first purpose of this module is to supply matplotlib stylesheets to assist in the creation of scientific figures. Since matplotlib 3.7.0, this has become quite easy. This module is still useful to collect stylesheets.

The stylesheets stored under src/scistyles are discovered by matplotlib. Simply use them:

import matplotlib.pyplot as plt
import scistyles

plt.style.use("scistyles.presentation-sp")
# plot away!

The module also provides a simple tool to format numbers with errors, such that the number in parentheses indicates the error on the last digits, ready to add to a plot.

from scistyles.format import format_value_error
l = format_value_error(3.14159265, 0.1234) # "3.14(12)"
# the number of decimals can be controlled:
l = format_value_error(3.14159265, 0.1234, nd=1) # "3.1(1)"

If you use lmfit, you can use them directly on the Parameter in the fit results.

from scistyles.format import format_parameter
# get some data, setup some fit model.
result = model.fit(...)
label = format_parameter(result.params["important_variable"])

Contributing

Contributions are welcome! In case you have strong disagreement with our choice of tick width or legend handlelength, then fine, just contribute your own stylesheet. We won't argue1, and just add it to the pile. Simply make sure to give the stylesheet a name that is not already taken.

To contribute a stylesheet, just write an issue. For large contributions, a PR would be appreciated.

See also

For everything about rcParams and stylesheets, see the official matplotlib documentation.

TODO

  • Add a test plot and autogenerated gallery.
  • add a few further design tools (colors, palettes...)
  • Figure a way to store misc info such as two-column figure width, preferred sublabel formats.

Notes

Footnotes

  1. We aren't talking about colormaps. ↩

About

Matplotlib stylesheets and figure design tools.

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages