Skip to content

Commit

Permalink
correctly handle rc defaults (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathematicalmichael authored Jan 22, 2024
1 parent 544f1a9 commit 86cdf62
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/mud/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

def _check_latex():
"""check latex installation"""

original_params = plt.rcParams.copy()
path = Path.cwd() / ".test_fig.png"
try: # minimal example to trip up matplotlib
plt.rcParams.update({"text.usetex": True})
Expand All @@ -35,9 +35,12 @@ def _check_latex():
except (RuntimeError, FileNotFoundError):
_logger.warning("NOT USING TEX")
return False
finally:
plt.rcParams.update(original_params) # Restore the original parameters
plt.close("all") # Close all figures to release any resources


# Matplotlib plotting options
# # Matplotlib plotting options
HAS_LATEX = _check_latex()
PREAMBLE = ""
if HAS_LATEX:
Expand Down Expand Up @@ -84,7 +87,6 @@ def save_figure(
"""
global mud_plot_params

fname = str(Path(save_path) / Path(fname))
plt.savefig(fname, **kwargs)
Expand Down

0 comments on commit 86cdf62

Please sign in to comment.