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

Skip to content

Commit 54cf23c

Browse files
committed
Fix alpha-handling bug in ColorConverter, duplicate color calculation in contour.
svn path=/trunk/matplotlib/; revision=2737
1 parent c14ae4c commit 54cf23c

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

lib/matplotlib/colors.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,12 +429,16 @@ def to_rgb(self, arg, warn=True):
429429

430430
return color
431431

432-
def to_rgba(self, arg, alpha=1.0, warn=True):
432+
def to_rgba(self, arg, alpha=None, warn=True):
433433
"""
434434
Returns an RGBA tuple of four floats from 0-1.
435435
436436
For acceptable values of arg, see to_rgb.
437437
"""
438+
if not is_string_like(arg) and iterable(arg) and len(arg) == 4:
439+
alpha = float(arg[3])
440+
elif alpha is None:
441+
alpha = 1.0
438442
r,g,b = self.to_rgb(arg, warn)
439443
return r,g,b,alpha
440444

lib/matplotlib/contour.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ def _process_colors(self):
680680
if self.extend in ('both', 'max', 'min'):
681681
self.norm.clip = False
682682
self.set_array(self.layers)
683-
self.tcolors = [ (tuple(rgba),) for rgba in self.to_rgba(self.cvalues)]
683+
# self.tcolors will be set by the "changed" method
684684

685685
def _process_linewidths(self):
686686
linewidths = self.linewidths

0 commit comments

Comments
 (0)