Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save christopherlovell/620072e203a91c2f06c28c514c7f3345 to your computer and use it in GitHub Desktop.
Save christopherlovell/620072e203a91c2f06c28c514c7f3345 to your computer and use it in GitHub Desktop.
Matplotlib Stylesheet for creating SM style plots

To use this stylesheet, you need to put it inside your mplconfig_dir. By default, mpl_configdir should be ~/.config/matplotlib, but you can check where yours is with matplotlib.get_configdir(). You can then import it with styleuse('sm').

Based on work by Monica L. Turner, http://space.mit.edu/~turnerm/python.html (accessed 5/7/2016)

# Simplify paths by removing "invisible" points, useful for reducing
# file size when plotting a large number of points
path.simplify : True
# Instead of individually increasing font sizes, point sizes, and line
# thicknesses, I found it easier to just decrease the figure size so
# that the line weights of various components still agree
figure.figsize : 4,4
# I am still working on getting fonts as nice as those in SM. In the
# meantime, I have settled for having the fonts in math mode agree
# with the regular ones.
font.family : serif
mathtext.fontset : custom
# Increase the tick-mark lengths (defaults are 4 and 2)
xtick.major.size : 6
ytick.major.size : 6
xtick.minor.size : 3
ytick.minor.size : 3
# Increase the tick-mark widths as well as the widths of lines
# used to draw marker edges to be consistent with the other figure
# linewidths (defaults are all 0.5)
xtick.major.width : 1
ytick.major.width : 1
xtick.minor.width : 1
ytick.minor.width : 1
lines.markeredgewidth : 1
# Have the legend only plot one point instead of two, turn off the
# frame, and reduce the space between the point and the label
legend.numpoints : 1
legend.frameon : False
legend.handletextpad : 0.3
## https://gist.github.com/beckermr/62a9f99ad9b275df12dc
#lines
#lines.linewidth : 1.0
#lines.linestyle : -
#lines.color : black
#
##fonts & text
#font.weight : normal
#font.size : 12.0
#text.color : black
#text.usetex : True
##axes & ticks
#axes.edgecolor : black
#axes.linewidth : 1.0
#axes.grid : False
#axes.titlesize : x-large
#axes.labelsize : x-large
#axes.labelweight : normal
#axes.labelcolor : black
#axes.formatter.limits : -4, 4
#
#xtick.major.size : 7
#xtick.minor.size : 4
#xtick.major.pad : 6
#xtick.minor.pad : 6
#xtick.labelsize : x-large
#xtick.minor.width : 1.0
#xtick.major.width : 1.0
#
#ytick.major.size : 7
#ytick.minor.size : 4
#ytick.major.pad : 6
#ytick.minor.pad : 6
#ytick.labelsize : x-large
#
##legends
#legend.fontsize : x-large
#legend.shadow : False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment