Skip to content

Commit

Permalink
better perfs
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Sep 17, 2021
1 parent cb12c94 commit 2723612
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions yt/visualization/plot_container.py
@@ -1,8 +1,9 @@
import base64
import builtins
import os
import sys
import textwrap
from collections import ChainMap, defaultdict
from collections import defaultdict
from functools import wraps

import matplotlib
Expand Down Expand Up @@ -271,9 +272,12 @@ def __init__(self, data_source, figure_size, fontsize):
else:
self.figure_size = float(figure_size)

font_props = _DEFAULT_FONT_PROPERTIES.copy()
font_props["size"] = fontsize
self._font_properties = FontProperties(**font_props)
if sys.version_info >= (3, 9):
font_dict = _DEFAULT_FONT_PROPERTIES | {"size": fontsize}
else:
font_dict = {**_DEFAULT_FONT_PROPERTIES, "size": fontsize}

self._font_properties = FontProperties(**font_dict)
self._font_color = None
self._xlabel = None
self._ylabel = None
Expand Down Expand Up @@ -528,8 +532,11 @@ def set_font(self, font_dict=None):
self._font_color = font_dict.pop("color")
# Set default values if the user does not explicitly set them.
# this prevents reverting to the matplotlib defaults.
font_props = ChainMap(font_dict, _DEFAULT_FONT_PROPERTIES)
self._font_properties = FontProperties(**font_props)
if sys.version_info >= (3, 9):
font_dict = _DEFAULT_FONT_PROPERTIES | font_dict
else:
font_dict = {**_DEFAULT_FONT_PROPERTIES, **font_dict}
self._font_properties = FontProperties(**font_dict)
return self

def set_font_size(self, size):
Expand Down

0 comments on commit 2723612

Please sign in to comment.