Format Matplotlib for scientific plotting
This repo has Matplotlib styles to format your plots for scientific papers, presentations and theses.
Put 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). If you're on macOS, you can run:
mkdir -p ~/.matplotlib/stylelib/
cp styles/*.mplstyle ~/.matplotlib/stylelib/
science.mplstyle
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 main science
style in order to configure the plot for IEEE papers (column width, fontsize, etc.).
To use any of the styles temporarily, you can use:
with plt.style.context(['science', 'subfigure']):
plt.figure()
plt.plot(x, y)
plt.show()
Please feel free to add to this repo! For example, it would be good to add styles for different journals or perhaps new color cycles.
The science
style:
The science
+ high-vis
styles:
The science
+ scatter
styles:
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!
The science
+ bright
styles:
The science
+ vibrant
styles:
The science
+ muted
styles:
Note: The 3 styles above are from Paul Tot's website (https://personal.sron.nl/~pault/).