sciplotlib
sciplotlib is just a set of simple functions and stylesheets for more professional looking plots
There are two main properties that make plots in papers look the way they do:
- default style properties such as typeface, color scheme,
- specific choices in terms of the placement of tick marks, or additional elements that are added to the plot such as shading or shadows
Stylesheets
sciplotlib aims to make (1) easier by providing stylesheets that aims to mimic the style properties found in scientific papers:
We can compare the default matplotlib style with a style that mimics scatter plots found in articles from the Nature publishing group:
import matplotlib.pyplot as plt
import numpy as np
def make_plot():
fig, ax = plt.subplots()
num_categories = 10
num_points = 10
for category in np.arange(num_categories):
x = np.random.normal(size=num_points)
y = np.random.normal(size=num_points)
ax.scatter(x, y)
return fig, ax
fig, ax = make_plot()
ax.set_title('Default matplotlib style')
Applying the most basic style is just one line of code
from sciplotlib import style as spstyle
with plt.style.context(spstyle.get_style('nature-reviews')):
fig, ax = make_plot()
ax.set_title('Nature reviews style')
Modifying figure properties
sciplotlib also aims to make (2) easier by providing functions that automically add elements found in scientific plots. For example, in many scientific journals it is common for the axis to extend only from and up to the last tick mark, and in figures found in Nature review articles, it is also common that shading will be added to plots, these are implemented by functions that simpy takes in the figure handles and return them:
from sciplotlib import style as spstyle
from sciplotlib import polish as sppolish
with plt.style.context(spstyle.get_style('nature-reviews')):
fig, ax = make_plot()
fig, ax = sppolish.set_bounds(fig, ax)
sppolish.apply_gradient(ax, extent=None,
direction=0.3, cmap_range=(0.1, 0),
cmap='Greys')
ax.set_title('Nature reviews style with bells and whistles')
Installation
Simply do
pip install sciplotlib
Acknowledgments
sciplotlib is built on top of matplotlib. To cite matplotlib in your publications, cite:
J. D. Hunter, "Matplotlib: A 2D Graphics Environment", Computing in Science & Engineering, vol. 9, no. 3, pp. 90-95, 2007
Other projects that is also built on the idea of providing stylesheets / wrappers for scientific plots include:
Color palettes of scientific papers are obtained from the wonderful ggsci library:
https://cran.r-project.org/web/packages/ggsci/vignettes/ggsci.html
Contributing
Do contact me if you are interested in adding new functions or templates to this repository.
Metadata
Release files for sciplotlib 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sciplotlib-0.0.3.tar.gz | 28.3 kB | Without provenance | Details |
Release files / sciplotlib-0.0.3.tar.gz
| Download URL | sciplotlib-0.0.3.tar.gz |
|---|---|
| Size | 28.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
20587d61a685e396e7ca77ed1fc2f8fcb7585a6a600085a6ff6f2c9b1bf2f93c
|
|
BLAKE2b-256 checksum How to use checksums |
15572bde703ee0890a332986a6a5765e3acc2db5f7ec3abe8476c789a5877b3e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2
|
Security for sciplotlib 0.0.3
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.