Sets matplotlib parameters for scientific publishing.
Project description
Scientific style for matplotlib on import
The default font, font size, figure size, color shceme, linewidth, marker size etc. are not suited for scientific publications. This package sets the defaults to suitable parameters on import, and offers some handy functions for setting new defaults or cycling props.
Install
Use pip package
pip install pltparams
Or download the repo to your computer
cd path/to/pltparams
pip install .
Usage
import pltparams
sets the appropriate rc params for scientific style.
Alternatively:
import pltparams
pltparams.set_params()
The defualt colorscheme has some hard to see colors for white backgrounds, especially if it defaults to the darkmode theme. The 'tab10'colorshcme is good for white background, and is defualt here. Call use_tab10_color to revert back to it.
For black and white, we call use_classic_bw_style() for different linestyles and markers instead of color. This is probably the most useful command.
There's also an alternate use_okabe_ito_color() if you prefer the okabe ito color scheme.
Cycle through the markers by simply calling next(pltparams.marker_cycle). This is the easiest way, as setting default markers will also impose them on plot()in addition to scatter().
# Plot single column (Default style )
fig, ax = plt.subplots(1,1,figsize = pltparams.figsize_single)
plot_example(ax)
For the "classic" black and white style
pltparams.use_classic_bw_lines()
fig, ax = plt.subplots(1,1,figsize = pltparams.figsize_single)
plot_example(ax)
Alternate okabe ito color scheme
pltparams.use_okabe_ito_color()
fig, ax = plt.subplots(1,1,figsize = pltparams.figsize_single)
plot_example(ax)
Cycle props
We can fetch the next marker using next(marker_cycle), to easily grab the next markers. This is the easiest way to do this, as marker prop cycles can not be set in the defualt RCParams.
ax.scatter(x_scatter, y_scatter, marker = next(pltparams.marker_cycle), label="data 1 scatter")
There's also a letter_labels_lc and letter_labels_uc for lower case, and upper case, letters. This is handy for subplots.
ax.set_title(pltparams.letter_labels_lc[j]+") : "+subplot_labels[j], loc='left')
Alternatively copy paste this
These are the params the package will change, feel free to copy/paste if you prefer that
params = {"ytick.color" : "black",
"xtick.color" : "black",
"axes.labelcolor" : "black",
"axes.edgecolor" : "black",
"text.usetex" : True,
"font.family" : "serif",
"font.serif" : ["Computer Modern Serif"],
"axes.labelsize": 10,
"axes.titlesize": 10,
"xtick.labelsize": 10,
"ytick.labelsize": 10,
"legend.fontsize": 7,
"figure.figsize": figsize/ 25.4,
'figure.constrained_layout.use': True,
'figure.constrained_layout.hspace': 0.01,
'figure.constrained_layout.wspace': 0.01,
'figure.constrained_layout.h_pad': 0.02167,
'figure.constrained_layout.w_pad': 0.02167,
#'figure.autolayout': True,
'lines.linewidth' : 0.5,
'figure.facecolor' : "white",
'axes.facecolor' : "white",
'text.color' : 'black',
'axes.titlecolor' : 'black',
'savefig.facecolor' : 'white',
'savefig.dpi' : '300',
'savefig.format' : 'pdf',
}
plt.rcParams.update(params)
plt.rcParams['figure.constrained_layout.use'] = True
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pltparams-1.0.0.tar.gz.
File metadata
- Download URL: pltparams-1.0.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26c55790363e4f1cd61ed4086580a1c545d186fc935b4033dc1e36c3ad8e5c17
|
|
| MD5 |
e8caa7700d0eb4d41f918243e94dbf23
|
|
| BLAKE2b-256 |
a7c42d3430e24bed158e64767f2161c789246f60e8d28d001a164be8489ddc67
|
File details
Details for the file pltparams-1.0.0-py3-none-any.whl.
File metadata
- Download URL: pltparams-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
819db70d5481c226749b05505c74f315f574bd296558955f18895ec0a465147f
|
|
| MD5 |
5ad711e9bd6250ae7876e3a306849be4
|
|
| BLAKE2b-256 |
6980f4aacc4af8c6328402c982c9ff8f384a3c2303a6ef34ceda67f3a86ac507
|