Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e048bf1

Browse files
committed
Fix antialiased default in LineCollection; add comments
1 parent b639e0f commit e048bf1

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

lib/matplotlib/collections.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ def __init__(self,
170170
# list of unbroadcast/scaled linewidths
171171
self._us_lw = [0]
172172
self._linewidths = [0]
173-
# Flags: do colors come from mapping an array?
173+
# Flags set by _set_mappable_flags: are colors from mapping an array?
174174
self._face_is_mapped = None
175175
self._edge_is_mapped = None
176-
self._mapped_colors = None # Calculated in update_scalarmappable
176+
self._mapped_colors = None # calculated in update_scalarmappable
177177
self._hatch_color = mcolors.to_rgba(mpl.rcParams['hatch.color'])
178178
self.set_facecolor(facecolors)
179179
self.set_edgecolor(edgecolors)
@@ -736,10 +736,13 @@ def set_antialiased(self, aa):
736736
aa : bool or list of bools
737737
"""
738738
if aa is None:
739-
aa = mpl.rcParams['patch.antialiased']
739+
aa = self._get_default_antialiased()
740740
self._antialiaseds = np.atleast_1d(np.asarray(aa, bool))
741741
self.stale = True
742742

743+
def _get_default_antialiased(self):
744+
return mpl.rcParams['patch.antialiased']
745+
743746
def set_color(self, c):
744747
"""
745748
Set both the edgecolor and the facecolor.
@@ -868,11 +871,14 @@ def _set_mappable_flags(self):
868871
869872
Returns
870873
-------
871-
mapping_change: bool
874+
mapping_change : bool
872875
True if either flag is True, or if a flag has changed.
873876
"""
877+
# The flags are initialized to None to ensure this returns True
878+
# the first time it is called.
874879
edge0 = self._edge_is_mapped
875880
face0 = self._face_is_mapped
881+
# After returning, the flags must be Booleans, not None.
876882
self._edge_is_mapped = False
877883
self._face_is_mapped = False
878884
if self._A is not None:
@@ -1506,6 +1512,9 @@ def _add_offsets(self, segs):
15061512
def _get_default_linewidth(self):
15071513
return mpl.rcParams['lines.linewidth']
15081514

1515+
def _get_default_antialiased(self):
1516+
return mpl.rcParams['lines.antialiased']
1517+
15091518
def _get_default_edgecolor(self):
15101519
return mpl.rcParams['lines.color']
15111520

0 commit comments

Comments
 (0)