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

Skip to content

Commit efb68e0

Browse files
committed
Merge pull request matplotlib#901 from mdboom/quad_mesh_color
pcolormesh edgecolors does not work correctly
2 parents a638c9c + 41fcab5 commit efb68e0

File tree

10 files changed

+299
-328
lines changed

10 files changed

+299
-328
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2012-05-29 pcolormesh now obeys the passed in "edgecolor" kwarg.
2+
To support this, the "shading" argument to pcolormesh now only
3+
takes "flat" or "gouraud". To achieve the old "faceted" behavior,
4+
pass "edgecolors='k'". - MGD
5+
16
2012-05-22 Added radius kwarg to pie charts. - HH
27

38
2012-05-22 Collections now have a setting "offset_position" to select whether

lib/matplotlib/axes.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7164,14 +7164,10 @@ def pcolormesh(self, *args, **kwargs):
71647164
and max of the color array *C* is used. If you pass a
71657165
*norm* instance, *vmin* and *vmax* will be ignored.
71667166
7167-
*shading*: [ 'flat' | 'faceted' | 'gouraud' ]
7168-
If 'faceted', a black grid is drawn around each rectangle; if
7169-
'flat', edges are not drawn. Default is 'flat', contrary to
7170-
MATLAB.
7171-
7172-
This kwarg is deprecated; please use 'edgecolors' instead:
7173-
* shading='flat' -- edgecolors='None'
7174-
* shading='faceted -- edgecolors='k'
7167+
*shading*: [ 'flat' | 'gouraud' ]
7168+
'flat' indicates a solid color for each quad. When
7169+
'gouraud', each quad will be Gouraud shaded. When gouraud
7170+
shading, edgecolors is ignored.
71757171
71767172
*edgecolors*: [ *None* | ``'None'`` | color | color sequence]
71777173
If *None*, the rc setting is used by default.
@@ -7205,7 +7201,6 @@ def pcolormesh(self, *args, **kwargs):
72057201
vmin = kwargs.pop('vmin', None)
72067202
vmax = kwargs.pop('vmax', None)
72077203
shading = kwargs.pop('shading', 'flat').lower()
7208-
edgecolors = kwargs.pop('edgecolors', 'None')
72097204
antialiased = kwargs.pop('antialiased', False)
72107205

72117206
X, Y, C = self._pcolorargs('pcolormesh', *args)
@@ -7224,13 +7219,8 @@ def pcolormesh(self, *args, **kwargs):
72247219
coords[:, 0] = X
72257220
coords[:, 1] = Y
72267221

7227-
if shading == 'faceted' or edgecolors != 'None':
7228-
showedges = 1
7229-
else:
7230-
showedges = 0
7231-
72327222
collection = mcoll.QuadMesh(
7233-
Nx - 1, Ny - 1, coords, showedges,
7223+
Nx - 1, Ny - 1, coords,
72347224
antialiased=antialiased, shading=shading, **kwargs)
72357225
collection.set_alpha(alpha)
72367226
collection.set_array(C)

lib/matplotlib/backend_bases.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
224224

225225
def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
226226
coordinates, offsets, offsetTrans, facecolors,
227-
antialiased, showedges):
227+
antialiased, edgecolors):
228228
"""
229229
This provides a fallback implementation of
230230
:meth:`draw_quad_mesh` that generates paths and then calls
@@ -234,12 +234,9 @@ def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
234234
paths = QuadMesh.convert_mesh_to_paths(
235235
meshWidth, meshHeight, coordinates)
236236

237-
if showedges:
238-
edgecolors = np.array([[0.0, 0.0, 0.0, 1.0]], np.float_)
239-
linewidths = np.array([gc.get_linewidth()], np.float_)
240-
else:
237+
if edgecolors is None:
241238
edgecolors = facecolors
242-
linewidths = np.array([gc.get_linewidth()], np.float_)
239+
linewidths = np.array([gc.get_linewidth()], np.float_)
243240

244241
return self.draw_path_collection(
245242
gc, master_transform, paths, [], offsets, offsetTrans, facecolors,

lib/matplotlib/backends/backend_template.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def draw_path(self, gc, path, transform, rgbFace=None):
9898
# performance will probably want to implement it
9999
# def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
100100
# coordinates, offsets, offsetTrans, facecolors,
101-
# antialiased, showedges):
101+
# antialiased, edgecolors):
102102
# pass
103103

104104
def draw_image(self, gc, x, y, im):
@@ -253,4 +253,3 @@ class FigureManagerTemplate(FigureManagerBase):
253253

254254

255255
FigureManager = FigureManagerTemplate
256-

lib/matplotlib/collections.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,15 +1301,14 @@ class QuadMesh(Collection):
13011301
at (0, 1), then at (0, 2) .. (0, meshWidth), (1, 0), (1, 1), and
13021302
so on.
13031303
1304-
*shading* may be 'flat', 'faceted' or 'gouraud'
1304+
*shading* may be 'flat', or 'gouraud'
13051305
"""
1306-
def __init__(self, meshWidth, meshHeight, coordinates, showedges,
1306+
def __init__(self, meshWidth, meshHeight, coordinates,
13071307
antialiased=True, shading='flat', **kwargs):
13081308
Collection.__init__(self, **kwargs)
13091309
self._meshWidth = meshWidth
13101310
self._meshHeight = meshHeight
13111311
self._coordinates = coordinates
1312-
self._showedges = showedges
13131312
self._antialiased = antialiased
13141313
self._shading = shading
13151314

@@ -1449,7 +1448,7 @@ def draw(self, renderer):
14491448
renderer.draw_quad_mesh(
14501449
gc, transform.frozen(), self._meshWidth, self._meshHeight,
14511450
coordinates, offsets, transOffset, self.get_facecolor(),
1452-
self._antialiased, self._showedges)
1451+
self._antialiased, self.get_edgecolors())
14531452
gc.restore()
14541453
renderer.close_group(self.__class__.__name__)
14551454

Binary file not shown.

0 commit comments

Comments
 (0)