Skip to content

Instantly share code, notes, and snippets.

@selflein
Last active September 6, 2021 18:52
Show Gist options
  • Save selflein/3c58773d71de61968d41c15673b2150c to your computer and use it in GitHub Desktop.
Save selflein/3c58773d71de61968d41c15673b2150c to your computer and use it in GitHub Desktop.
[Seaborn settings for paper plots] #matplotlib #publication
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
sns.set_style("ticks")
sns.set_context("paper", font_scale=1.0)
params = {
'text.usetex' : True,
'font.size' : 11,
"font.serif": [],
"font.sans-serif": [],
"font.monospace": [],
"pgf.rcfonts": False, # don't setup fonts from rc parameters
"font.family": "serif",
"text.latex.preamble": [
r"\usepackage{lmodern}",
r"\usepackage{amsmath}",
],
"pgf.preamble": [
r"\usepackage{lmodern}",
r"\usepackage{amsmath}",
],
}
import matplotlib.font_manager
plt.rcParams.update(params)
# Plot something here
ax.ticklabel_format(useMathText=True, scilimits=(3,0), style="sci")
sns.despine(ax=ax)
ax.figure.savefig("path/to/somewhere.png", pad_inches=0.0, bbox_inches="tight", dpi=300)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment