Revision: 7005
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7005&view=rev
Author: efiring
Date: 2009-03-25 19:27:28 +0000 (Wed, 25 Mar 2009)
Log Message:
-----------
Contouring handles nans in Z via masking.
(The bug in filled contouring with internal masked regions
remains.)
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/examples/pylab_examples/contourf_demo.py
trunk/matplotlib/lib/matplotlib/contour.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-03-24 01:57:26 UTC (rev 7004)
+++ trunk/matplotlib/CHANGELOG 2009-03-25 19:27:28 UTC (rev 7005)
@@ -1,5 +1,7 @@
-2009-03-20 Add AuxTransformBox in offsetbox.py to support some transformation.
- anchored_text.py example is enhanced and renamed
+2009-03-25 Make contour and contourf handle nan in their Z argument. - EF
+
+2009-03-20 Add AuxTransformBox in offsetbox.py to support some transformation.
+ anchored_text.py example is enhanced and renamed
(anchored_artists.py). - JJL
2009-03-20 Add "bar" connection style for annotation - JJL
Modified: trunk/matplotlib/examples/pylab_examples/contourf_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/contourf_demo.py 2009-03-24
01:57:26 UTC (rev 7004)
+++ trunk/matplotlib/examples/pylab_examples/contourf_demo.py 2009-03-25
19:27:28 UTC (rev 7005)
@@ -3,7 +3,9 @@
origin = 'lower'
#origin = 'upper'
-test_masking = False # There is a bug in filled contour masking.
+# The following controls only interior masking.
+test_masking = False # There is a bug in filled contour masking with
+ # interior masks.
if test_masking:
# Use a coarse grid so only a few masked points are needed.
@@ -30,6 +32,18 @@
Z[0,0] = 0
Z = ma.array(Z, mask=badmask)
+nr, nc = Z.shape
+
+# put NaNs in one corner:
+Z[-nr//6:, -nc//6:] = nan
+# contourf will convert these to masked
+
+
+Z = ma.array(Z)
+# mask another corner:
+Z[:nr//6, :nc//6] = ma.masked
+
+
# We are using automatic selection of contour levels;
# this is usually not such a good idea, because they don't
# occur on nice boundaries, but we do it here for purposes
@@ -48,7 +62,7 @@
origin=origin,
hold='on')
-title('Nonsense')
+title('Nonsense (with 2 masked corners)')
xlabel('word length anomaly')
ylabel('sentence length anomaly')
@@ -72,7 +86,7 @@
colors = ('k',),
linewidths = (3,),
origin = origin)
-title('Listed colors')
+title('Listed colors (with 2 masked corners)')
clabel(CS4, fmt = '%2.1f', colors = 'w', fontsize=14)
colorbar(CS3)
Modified: trunk/matplotlib/lib/matplotlib/contour.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/contour.py 2009-03-24 01:57:26 UTC (rev
7004)
+++ trunk/matplotlib/lib/matplotlib/contour.py 2009-03-25 19:27:28 UTC (rev
7005)
@@ -756,6 +756,7 @@
x,y,z = self._check_xyz(args[:3])
else:
raise TypeError("Too many arguments to %s; see help(%s)" % (fn,fn))
+ z = ma.masked_invalid(z, copy=False)
self.zmax = ma.maximum(z)
self.zmin = ma.minimum(z)
if self.logscale and self.zmin <= 0:
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins