Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 06d8b29

Browse filesBrowse files
committed
generate list of path effects in RcParams object
1 parent 1a6db57 commit 06d8b29
Copy full SHA for 06d8b29

File tree

3 files changed

+17
-12
lines changed
Filter options

3 files changed

+17
-12
lines changed

‎lib/matplotlib/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/__init__.py
+15-1Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@
163163
from matplotlib._api import MatplotlibDeprecationWarning
164164
from matplotlib.rcsetup import validate_backend, cycler
165165

166-
167166
_log = logging.getLogger(__name__)
168167

169168
__bibtex__ = r"""@Article{Hunter:2007,
@@ -809,6 +808,21 @@ def copy(self):
809808
rccopy._set(k, self._get(k))
810809
return rccopy
811810

811+
def _load_path_effects(self):
812+
"""defers loading of patheffects to avoid circular imports"""
813+
import matplotlib.patheffects as path_effects
814+
815+
path_effects_list = self._get('path.effects').copy()
816+
print("before_loop: ", path_effects_list)
817+
for k, v in self.find_all('path.effects.').items():
818+
if v is None:
819+
continue
820+
path_effect_name = k.split('.')[-1]
821+
path_effect_function = getattr(path_effects, path_effect_name)
822+
path_effects_list.append(path_effect_function(**v))
823+
print("after_loop: ", path_effects_list)
824+
return path_effects_list
825+
812826

813827
def rc_params(fail_on_error=False):
814828
"""Construct a `RcParams` instance from the default Matplotlib rc file."""

‎lib/matplotlib/artist.py

Copy file name to clipboardExpand all lines: lib/matplotlib/artist.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def __init__(self):
209209
self._gid = None
210210
self._snap = None
211211
self._sketch = mpl.rcParams['path.sketch']
212-
self._path_effects = []
212+
self._path_effects = mpl.rcParams._load_path_effects()
213213
self._sticky_edges = _XYPair([], [])
214214
self._in_layout = True
215215

‎lib/matplotlib/patheffects.py

Copy file name to clipboardExpand all lines: lib/matplotlib/patheffects.py
+1-10Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55
.. seealso::
66
:ref:`patheffects_guide`
77
"""
8-
import sys
98

10-
import matplotlib as mpl
119
from matplotlib.backend_bases import RendererBase
12-
import matplotlib.cbook as cbook
1310
from matplotlib import colors as mcolors
1411
from matplotlib import patches as mpatches
1512
from matplotlib import transforms as mtransforms
@@ -93,13 +90,7 @@ def __init__(self, path_effects, renderer):
9390
renderer : `~matplotlib.backend_bases.RendererBase` subclass
9491
9592
"""
96-
compound_path_effects = mpl.rcParams['path.effects']
97-
for k, v in mpl.rcParams.find_all('path.effects.*').copy().items():
98-
if path_effect_name := k.lstrip('path.effects') and v is not None:
99-
path_effect_function = sys.modules[__name__].__dict__[path_effect_name]
100-
compound_path_effects.append(path_effect_function(**v))
101-
compound_path_effects.append(path_effects)
102-
self._path_effects = cbook.flatten(compound_path_effects)
93+
self._path_effects = path_effects
10394
self._renderer = renderer
10495

10596
def copy_with_path_effect(self, path_effects):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.