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

Skip to content

Commit b59004d

Browse files
committed
Fix no-fill bug introduced in r5976
svn path=/trunk/matplotlib/; revision=5979
1 parent 4e4b94f commit b59004d

3 files changed

Lines changed: 18 additions & 36 deletions

File tree

lib/matplotlib/axes.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5195,26 +5195,14 @@ def hexbin(self, x, y, C = None, gridsize = 100, bins = None,
51955195
ymax = 10**ymax
51965196
self.set_yscale('log')
51975197

5198-
class HexagonBinCollection(mcoll.PolyCollection):
5199-
"""A HexagonBinCollection is a PolyCollection where the edge
5200-
colors are always kept equal to the fill colors"""
5201-
def update_scalarmappable(self):
5202-
mcoll.PolyCollection.update_scalarmappable(self)
5203-
self._edgecolors = self._facecolors
5204-
52055198
if edgecolors=='none':
5206-
collection = HexagonBinCollection(
5207-
polygons,
5208-
linewidths = linewidths,
5209-
transOffset = self.transData,
5210-
)
5211-
else:
5212-
collection = mcoll.PolyCollection(
5213-
polygons,
5214-
edgecolors = edgecolors,
5215-
linewidths = linewidths,
5216-
transOffset = self.transData,
5217-
)
5199+
edgecolors = 'face'
5200+
collection = mcoll.PolyCollection(
5201+
polygons,
5202+
edgecolors = edgecolors,
5203+
linewidths = linewidths,
5204+
transOffset = self.transData,
5205+
)
52185206

52195207
# Transform accum if needed
52205208
if bins=='log':

lib/matplotlib/collections.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
they are meant to be fast for common use cases (e.g. a bunch of solid
99
line segemnts)
1010
"""
11-
import math, warnings
11+
import copy, math, warnings
1212
import numpy as np
1313
import numpy.ma as ma
1414
import matplotlib as mpl
@@ -331,8 +331,8 @@ def set_facecolor(self, c):
331331
ACCEPTS: matplotlib color arg or sequence of rgba tuples
332332
"""
333333
if c is None: c = mpl.rcParams['patch.facecolor']
334-
self._facecolors = _colors.colorConverter.to_rgba_array(c, self._alpha)
335334
self._facecolors_original = c
335+
self._facecolors = _colors.colorConverter.to_rgba_array(c, self._alpha)
336336

337337
set_facecolors = set_facecolor
338338

@@ -361,10 +361,11 @@ def set_edgecolor(self, c):
361361
"""
362362
if c == 'face':
363363
self._edgecolors = 'face'
364+
self._edgecolors_original = 'face'
364365
else:
365366
if c is None: c = mpl.rcParams['patch.edgecolor']
366-
self._edgecolors = _colors.colorConverter.to_rgba_array(c, self._alpha)
367367
self._edgecolors_original = c
368+
self._edgecolors = _colors.colorConverter.to_rgba_array(c, self._alpha)
368369

369370
set_edgecolors = set_edgecolor
370371

@@ -385,8 +386,9 @@ def set_alpha(self, alpha):
385386
except (AttributeError, TypeError, IndexError):
386387
pass
387388
try:
388-
self._edgecolors = _colors.colorConverter.to_rgba_array(
389-
self._edgecolors_original, self._alpha)
389+
if self._edgecolors_original != 'face':
390+
self._edgecolors = _colors.colorConverter.to_rgba_array(
391+
self._edgecolors_original, self._alpha)
390392
except (AttributeError, TypeError, IndexError):
391393
pass
392394

@@ -809,7 +811,7 @@ def __init__(self, segments, # Can be None.
809811
pickradius=pickradius,
810812
**kwargs)
811813

812-
self._facecolors = np.array([])
814+
self.set_facecolors([])
813815
self.set_segments(segments)
814816

815817
def get_paths(self):

lib/matplotlib/colors.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -332,26 +332,18 @@ def to_rgba_array(self, c, alpha=None):
332332
if len(c) == 0:
333333
return np.zeros((0,4), dtype=np.float_)
334334
try:
335-
result = [self.to_rgba(c, alpha)]
335+
result = np.array([self.to_rgba(c, alpha)], dtype=np.float_)
336336
except ValueError:
337337
# If c is a list it must be maintained as the same list
338338
# with modified items so that items can be appended to
339339
# it. This is needed for examples/dynamic_collections.py.
340340
if isinstance(c, np.ndarray):
341341
if len(c.shape) != 2:
342342
raise ValueError("Color array must be two-dimensional")
343-
if c.shape[1] != 4:
344-
output = np.zeros((c.shape[0], 4))
345-
else:
346-
output = c
347-
elif not isinstance(c, list):
348-
output = list(c)
349-
else:
350-
output = c
351343

344+
result = np.zeros((len(c), 4))
352345
for i, cc in enumerate(c):
353-
output[i] = self.to_rgba(cc, alpha) # change in place
354-
result = output
346+
result[i] = self.to_rgba(cc, alpha) # change in place
355347
return np.asarray(result, np.float_)
356348

357349
colorConverter = ColorConverter()

0 commit comments

Comments
 (0)