Created
September 3, 2020 12:39
-
-
Save cobalamin/10ed5fd87ab8257e6a57e44bd66a2529 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
class Paper(object): | |
def __init__(self, force_inline=True): | |
from copy import copy | |
self.orig_rc = copy(plt.rcParams) | |
self.force_inline = force_inline | |
def __enter__(self): | |
if self.force_inline: | |
get_ipython().magic('matplotlib inline') | |
plt.rcParams['text.usetex'] = True | |
plt.rcParams['text.latex.preamble'] = '\DeclareUnicodeCharacter{2212}{-}' | |
plt.rcParams['font.family'] = 'serif' | |
plt.rcParams['font.size'] = 16 | |
def __exit__(self, type, value, traceback): | |
plt.rcParams.update(self.orig_rc) | |
if self.force_inline: | |
get_ipython().magic('matplotlib notebook') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment