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

Skip to content

Commit 0af7578

Browse files
committed
In collections, keep track of whether edges or faces are colormapped.
Thanks to Eric Bruning for finding the problem and outlining the solution. svn path=/trunk/matplotlib/; revision=6607
1 parent e9a1fe5 commit 0af7578

1 file changed

Lines changed: 24 additions & 8 deletions

File tree

lib/matplotlib/collections.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def set_pickradius(self,pickradius): self.pickradius = 5
231231
def get_pickradius(self): return self.pickradius
232232

233233
def set_urls(self, urls):
234-
if urls is None:
234+
if urls is None:
235235
self._urls = [None,]
236236
else:
237237
self._urls = urls
@@ -365,11 +365,19 @@ def set_facecolor(self, c):
365365
"""
366366
Set the facecolor(s) of the collection. *c* can be a
367367
matplotlib color arg (all patches have same color), or a
368-
sequence or rgba tuples; if it is a sequence the patches will
369-
cycle through the sequence
368+
sequence of rgba tuples; if it is a sequence the patches will
369+
cycle through the sequence.
370+
371+
If *c* is 'none', the patch will not be filled.
370372
371373
ACCEPTS: matplotlib color arg or sequence of rgba tuples
372374
"""
375+
self._is_filled = True
376+
try:
377+
if c.lower() == 'none':
378+
self._is_filled = False
379+
except AttributeError:
380+
pass
373381
if c is None: c = mpl.rcParams['patch.facecolor']
374382
self._facecolors_original = c
375383
self._facecolors = _colors.colorConverter.to_rgba_array(c, self._alpha)
@@ -393,14 +401,21 @@ def set_edgecolor(self, c):
393401
"""
394402
Set the edgecolor(s) of the collection. *c* can be a
395403
matplotlib color arg (all patches have same color), or a
396-
sequence or rgba tuples; if it is a sequence the patches will
404+
sequence of rgba tuples; if it is a sequence the patches will
397405
cycle through the sequence.
398406
399407
If *c* is 'face', the edge color will always be the same as
400-
the face color.
408+
the face color. If it is 'none', the patch boundary will not
409+
be drawn.
401410
402411
ACCEPTS: matplotlib color arg or sequence of rgba tuples
403412
"""
413+
self._is_stroked = True
414+
try:
415+
if c.lower() == 'none':
416+
self._is_stroked = False
417+
except AttributeError:
418+
pass
404419
if c == 'face':
405420
self._edgecolors = 'face'
406421
self._edgecolors_original = 'face'
@@ -409,6 +424,7 @@ def set_edgecolor(self, c):
409424
self._edgecolors_original = c
410425
self._edgecolors = _colors.colorConverter.to_rgba_array(c, self._alpha)
411426

427+
412428
def set_edgecolors(self, c):
413429
"""alias for set_edgecolor"""
414430
return self.set_edgecolor(c)
@@ -452,9 +468,9 @@ def update_scalarmappable(self):
452468
if self._A is None: return
453469
if self._A.ndim > 1:
454470
raise ValueError('Collections can only map rank 1 arrays')
455-
if len(self._facecolors):
471+
if self._is_filled:
456472
self._facecolors = self.to_rgba(self._A, self._alpha)
457-
else:
473+
elif self._is_stroked:
458474
self._edgecolors = self.to_rgba(self._A, self._alpha)
459475

460476
def update_from(self, other):
@@ -887,6 +903,7 @@ def __init__(self, segments, # Can be None.
887903
Collection.__init__(
888904
self,
889905
edgecolors=colors,
906+
facecolors='none',
890907
linewidths=linewidths,
891908
linestyles=linestyles,
892909
antialiaseds=antialiaseds,
@@ -897,7 +914,6 @@ def __init__(self, segments, # Can be None.
897914
pickradius=pickradius,
898915
**kwargs)
899916

900-
self.set_facecolors([])
901917
self.set_segments(segments)
902918

903919
def get_paths(self):

0 commit comments

Comments
 (0)