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

Skip to content

pcolormesh edgecolors does not work correctly #901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 31, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2012-05-29 pcolormesh now obeys the passed in "edgecolor" kwarg.
To support this, the "shading" argument to pcolormesh now only
takes "flat" or "gouraud". To achieve the old "faceted" behavior,
pass "edgecolors='k'". - MGD

2012-05-22 Added radius kwarg to pie charts. - HH

2012-05-22 Collections now have a setting "offset_position" to select whether
Expand Down
20 changes: 5 additions & 15 deletions lib/matplotlib/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7164,14 +7164,10 @@ def pcolormesh(self, *args, **kwargs):
and max of the color array *C* is used. If you pass a
*norm* instance, *vmin* and *vmax* will be ignored.

*shading*: [ 'flat' | 'faceted' | 'gouraud' ]
If 'faceted', a black grid is drawn around each rectangle; if
'flat', edges are not drawn. Default is 'flat', contrary to
MATLAB.

This kwarg is deprecated; please use 'edgecolors' instead:
* shading='flat' -- edgecolors='None'
* shading='faceted -- edgecolors='k'
*shading*: [ 'flat' | 'gouraud' ]
'flat' indicates a solid color for each quad. When
'gouraud', each quad will be Gouraud shaded. When gouraud
shading, edgecolors is ignored.

*edgecolors*: [ *None* | ``'None'`` | color | color sequence]
If *None*, the rc setting is used by default.
Expand Down Expand Up @@ -7205,7 +7201,6 @@ def pcolormesh(self, *args, **kwargs):
vmin = kwargs.pop('vmin', None)
vmax = kwargs.pop('vmax', None)
shading = kwargs.pop('shading', 'flat').lower()
edgecolors = kwargs.pop('edgecolors', 'None')
antialiased = kwargs.pop('antialiased', False)

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

if shading == 'faceted' or edgecolors != 'None':
showedges = 1
else:
showedges = 0

collection = mcoll.QuadMesh(
Nx - 1, Ny - 1, coords, showedges,
Nx - 1, Ny - 1, coords,
antialiased=antialiased, shading=shading, **kwargs)
collection.set_alpha(alpha)
collection.set_array(C)
Expand Down
9 changes: 3 additions & 6 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,

def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
coordinates, offsets, offsetTrans, facecolors,
antialiased, showedges):
antialiased, edgecolors):
"""
This provides a fallback implementation of
:meth:`draw_quad_mesh` that generates paths and then calls
Expand All @@ -234,12 +234,9 @@ def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
paths = QuadMesh.convert_mesh_to_paths(
meshWidth, meshHeight, coordinates)

if showedges:
edgecolors = np.array([[0.0, 0.0, 0.0, 1.0]], np.float_)
linewidths = np.array([gc.get_linewidth()], np.float_)
else:
if edgecolors is None:
edgecolors = facecolors
linewidths = np.array([gc.get_linewidth()], np.float_)
linewidths = np.array([gc.get_linewidth()], np.float_)

return self.draw_path_collection(
gc, master_transform, paths, [], offsets, offsetTrans, facecolors,
Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/backends/backend_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def draw_path(self, gc, path, transform, rgbFace=None):
# performance will probably want to implement it
# def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
# coordinates, offsets, offsetTrans, facecolors,
# antialiased, showedges):
# antialiased, edgecolors):
# pass

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


FigureManager = FigureManagerTemplate

7 changes: 3 additions & 4 deletions lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -1301,15 +1301,14 @@ class QuadMesh(Collection):
at (0, 1), then at (0, 2) .. (0, meshWidth), (1, 0), (1, 1), and
so on.

*shading* may be 'flat', 'faceted' or 'gouraud'
*shading* may be 'flat', or 'gouraud'
"""
def __init__(self, meshWidth, meshHeight, coordinates, showedges,
def __init__(self, meshWidth, meshHeight, coordinates,
antialiased=True, shading='flat', **kwargs):
Collection.__init__(self, **kwargs)
self._meshWidth = meshWidth
self._meshHeight = meshHeight
self._coordinates = coordinates
self._showedges = showedges
self._antialiased = antialiased
self._shading = shading

Expand Down Expand Up @@ -1449,7 +1448,7 @@ def draw(self, renderer):
renderer.draw_quad_mesh(
gc, transform.frozen(), self._meshWidth, self._meshHeight,
coordinates, offsets, transOffset, self.get_facecolor(),
self._antialiased, self._showedges)
self._antialiased, self.get_edgecolors())
gc.restore()
renderer.close_group(self.__class__.__name__)

Expand Down
Binary file modified lib/matplotlib/tests/baseline_images/test_axes/pcolormesh.pdf
Binary file not shown.
Binary file modified lib/matplotlib/tests/baseline_images/test_axes/pcolormesh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading