Skip to content

Instantly share code, notes, and snippets.

@jorgecarleitao
Created July 4, 2017 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgecarleitao/90d636728e3c6133ce5748e7486fab9c to your computer and use it in GitHub Desktop.
Save jorgecarleitao/90d636728e3c6133ce5748e7486fab9c to your computer and use it in GitHub Desktop.
A minimal change of settings parameters for quality images with matplotlib
import matplotlib.pyplot as plt
def set_plot_settings(font_size=18):
# a font that is very close to LaTeX.
plt.rcParams['mathtext.fontset'] = 'stix'
plt.rcParams['font.family'] = 'STIXGeneral'
# ticks with the same width as axis, and consistent with font size (below)
plt.rcParams['axes.linewidth'] = 1
plt.rcParams['xtick.major.width'] = 1
plt.rcParams['ytick.major.width'] = 1
# set grid to be very light so it does not distract
plt.rcParams['grid.alpha'] = 0.2
# there is no reason for an alpha != 1 for the legend box (anything beneath it is distracting)
plt.rcParams['legend.framealpha'] = 1
# They should depend on the size you give to the figure, but should be equal.
plt.rcParams['axes.labelsize'] = font_size
plt.rcParams['xtick.labelsize'] = font_size
plt.rcParams['ytick.labelsize'] = font_size
plt.rcParams['legend.fontsize'] = font_size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment