SciencePlots: Matplotlib styles for scientific plotting
Science Plots
Matplotlib styles for scientific plotting
This repo has Matplotlib styles to format your plots for scientific papers, presentations and theses.
Installation
The easiest way to install SciencePlots is using
pip:# for latest version pip install git+https://github.com/garrettj403/SciencePlots.git # for last release pip install SciencePlotsThe pip installation will automatically move all of the
*.mplstylefiles into the appropriate directory. You can also do this manually, if you like. First, clone the repository and then copy all of the*.mplstylefiles 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*.mplstylefiles in/home/garrett/.matplotlib/stylelib/(you may need to create thestylelibdirectory).Using the Styles
science.mplstyleis 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
ieeestyle will override some of the parameters from the mainsciencestyle in order to configure the plot for IEEE papers (column width, fontsizes, etc.).To use any of the styles temporarily, you can use:
with plt.style.context(\['science', 'ieee'\]): plt.figure() plt.plot(x, y) plt.show()Examples
The
sciencestyle (the base style):The
science+gridstyles:The
science+ieeestyles for IEEE papers:IEEE requires figures to be readable when printed in black and white. The
ieeestyle also sets the figure width to fit within one column of an IEEE paper.The
science+scatterstyles for scatter plots:The
science+notebookstyles for Jupyter notebooks:You can also combine these styles with the other styles that come with Matplotlib. For example, the
dark_background+science+high-visstyles:Note: See the
examples/directory for more!Color Cycles
The
high-viscolor cycle:The
brightcolor cycle:The
vibrantcolor cycle:The
mutedcolor cycle:The
retrocolor cycle:Note: The
bright,vibrantandmutedcolor cycles are from Paul Tol’s website. They are color-blind safe!Contribution
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.
You can checkout Matplotlib’s documentation for more plotting options.
FAQ
Errors related to Latex:
- The default
sciencestyle uses Latex font rendering. If you do not have Latex on your computer or if you think that Latex takes too long, you can disable Latex using theno-latexstyle:plt.style.use(\['science','no-latex'\])- For Windows users, you may need to manually add Latex to your environment path (see issue).











