Skip to content

Commit ea89615

Browse files
committed
rcParams always exist.
1 parent e3a34c5 commit ea89615

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

lib/matplotlib/backends/backend_agg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ def print_jpg(self, filename_or_obj, *args, **kwargs):
569569
# The image is "pasted" onto a white background image to safely
570570
# handle any transparency
571571
image = Image.frombuffer('RGBA', size, buf, 'raw', 'RGBA', 0, 1)
572-
rgba = mcolors.to_rgba(rcParams.get('savefig.facecolor', 'white'))
572+
rgba = mcolors.to_rgba(rcParams['savefig.facecolor'])
573573
color = tuple([int(x * 255.0) for x in rgba[:3]])
574574
background = Image.new('RGB', size, color)
575575
background.paste(image, image)

lib/matplotlib/backends/backend_pgf.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
def get_texcommand():
5757
"""Get chosen TeX system from rc."""
5858
texsystem_options = ["xelatex", "lualatex", "pdflatex"]
59-
texsystem = rcParams.get("pgf.texsystem", "xelatex")
59+
texsystem = rcParams["pgf.texsystem"]
6060
return texsystem if texsystem in texsystem_options else "xelatex"
6161

6262

@@ -68,7 +68,7 @@ def get_fontspec():
6868
if texcommand != "pdflatex":
6969
latex_fontspec.append("\\usepackage{fontspec}")
7070

71-
if texcommand != "pdflatex" and rcParams.get("pgf.rcfonts", True):
71+
if texcommand != "pdflatex" and rcParams["pgf.rcfonts"]:
7272
# try to find fonts from rc parameters
7373
families = ["serif", "sans-serif", "monospace"]
7474
fontspecs = [r"\setmainfont{%s}", r"\setsansfont{%s}",
@@ -86,10 +86,7 @@ def get_fontspec():
8686

8787
def get_preamble():
8888
"""Get LaTeX preamble from rc."""
89-
latex_preamble = rcParams.get("pgf.preamble", "")
90-
if type(latex_preamble) == list:
91-
latex_preamble = "\n".join(latex_preamble)
92-
return latex_preamble
89+
return "\n".join(rcParams["pgf.preamble"])
9390

9491
###############################################################################
9592

@@ -223,13 +220,14 @@ def get_latex_manager():
223220
latex_header = LatexManager._build_latex_header()
224221
prev = LatexManagerFactory.previous_instance
225222

226-
# check if the previous instance of LatexManager can be reused
227-
if prev and prev.latex_header == latex_header and prev.texcommand == texcommand:
228-
if rcParams.get("pgf.debug", False):
223+
# Check if the previous instance of LatexManager can be reused.
224+
if (prev and prev.latex_header == latex_header
225+
and prev.texcommand == texcommand):
226+
if rcParams["pgf.debug"]:
229227
print("reusing LatexManager")
230228
return prev
231229
else:
232-
if rcParams.get("pgf.debug", False):
230+
if rcParams["pgf.debug"]:
233231
print("creating LatexManager")
234232
new_inst = LatexManager()
235233
LatexManagerFactory.previous_instance = new_inst
@@ -289,7 +287,7 @@ def __init__(self):
289287
# store references for __del__
290288
self._os_path = os.path
291289
self._shutil = shutil
292-
self._debug = rcParams.get("pgf.debug", False)
290+
self._debug = rcParams["pgf.debug"]
293291

294292
# create a tmp directory for running latex, remember to cleanup
295293
self.tmpdir = tempfile.mkdtemp(prefix="mpl_pgf_lm_")

0 commit comments

Comments
 (0)