Skip to content

Commit 016a4e0

Browse files
committed
Partial fix for pcolormesh problems reported by George Nurser.
svn path=/trunk/matplotlib/; revision=2382
1 parent 071c783 commit 016a4e0

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

boilerplate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def %(func)s(*args, **kwargs):
4747
# these methods are all simple wrappers of Axes methods by the same
4848
# name.
4949
_plotcommands = (
50-
'arrow',
50+
'arrow',
5151
'axhline',
5252
'axhspan',
5353
'axvline',
@@ -94,13 +94,13 @@ def %(func)s(*args, **kwargs):
9494
)
9595

9696
cmappable = {
97-
#'clabel' : 'if ret.mappable is not None: gci._current = ret.mappable',
9897
'contour' : 'if ret._A is not None: gci._current = ret',
9998
'contourf': 'if ret._A is not None: gci._current = ret',
10099
'scatter' : 'gci._current = ret',
101100
'pcolor' : 'gci._current = ret',
101+
'pcolormesh' : 'gci._current = ret',
102102
'imshow' : 'gci._current = ret',
103-
'spy2' : 'gci._current = ret',
103+
'spy2' : 'gci._current = ret',
104104
'specgram' : 'gci._current = ret[-1]',
105105

106106
}

examples/quadmesh_demo.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
ax.set_title('Without masked values')
3030

3131
ax = fig.add_subplot(122)
32-
cmap = cm.jet
33-
cmap.set_bad('w', 1.0)
34-
# We need to specify the norm so we can set clip to False;
35-
# probably this should be fixed so it would not be necessary.
36-
norm = colors.normalize(clip = False)
37-
ax.pcolormesh(Qx,Qz,Zm, cmap=cmap, norm=norm)
32+
# You can control the color of the masked region:
33+
#cmap = cm.jet
34+
#cmap.set_bad('r', 1.0)
35+
#ax.pcolormesh(Qx,Qz,Zm, cmap=cmap)
36+
# Or use the default, which is transparent:
37+
ax.pcolormesh(Qx,Qz,Zm)
3838
ax.set_title('With masked values')
3939
show()
4040

lib/matplotlib/colors.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,7 @@ def __init__(self, vmin=None, vmax=None, clip = True):
630630
minimum and maximum value respectively. If clip is True and
631631
the given value falls outside the range, the returned value
632632
will be 0 or 1, whichever is closer. Returns 0 if vmin==vmax.
633-
Works with scalars or arrays, including masked arrays. If clip
634-
is True, masked values on input will be set to 1 on output; if
635-
clip is False, the mask will be propagated to the output.
633+
Works with scalars or arrays, including masked arrays.
636634
"""
637635
self.vmin = vmin
638636
self.vmax = vmax
@@ -655,7 +653,8 @@ def __call__(self, value):
655653
return 0.*value
656654
else:
657655
if self.clip:
658-
val = clip(val.filled(vmax), vmin, vmax)
656+
val = ma.array(clip(val.filled(vmax), vmin, vmax),
657+
mask=val.mask)
659658
result = (val-vmin)/float(vmax-vmin)
660659
if vtype == 'scalar':
661660
result = result[0]

lib/matplotlib/pylab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1936,7 +1936,7 @@ def pcolormesh(*args, **kwargs):
19361936
except:
19371937
hold(b)
19381938
raise
1939-
1939+
gci._current = ret
19401940
hold(b)
19411941
return ret
19421942
if Axes.pcolormesh.__doc__ is not None:

0 commit comments

Comments
 (0)