Revision: 4081
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4081&view=rev
Author: efiring
Date: 2007-11-01 00:21:00 -0700 (Thu, 01 Nov 2007)
Log Message:
-----------
Made contour auto level generation work with log color scale
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/contour.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2007-11-01 03:40:06 UTC (rev 4080)
+++ trunk/matplotlib/CHANGELOG 2007-11-01 07:21:00 UTC (rev 4081)
@@ -1,3 +1,6 @@
+2007-10-31 Made log color scale easier to use with contourf;
+ automatic level generation now works. - EF
+
2007-10-24 Added ax kwarg to Figure.colorbar and pyplot.colorbar - EF
2007-10-19 Removed a gsave/grestore pair surrounding _draw_ps, which
Modified: trunk/matplotlib/lib/matplotlib/contour.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/contour.py 2007-11-01 03:40:06 UTC (rev
4080)
+++ trunk/matplotlib/lib/matplotlib/contour.py 2007-11-01 07:21:00 UTC (rev
4081)
@@ -401,6 +401,15 @@
self.antialiased = kwargs.get('antialiased', True)
self.nchunk = kwargs.get('nchunk', 0)
self.locator = kwargs.get('locator', None)
+ if (isinstance(norm, colors.LogNorm)
+ or isinstance(self.locator, ticker.LogLocator)):
+ self.logscale = True
+ if norm is None:
+ norm = colors.LogNorm()
+ if self.extend is not 'neither':
+ raise ValueError('extend kwarg does not work yet with log
scale')
+ else:
+ self.logscale = False
if self.origin is not None: assert(self.origin in
['lower', 'upper', 'image'])
@@ -493,7 +502,10 @@
three levels to provide boundaries for both regions.
'''
if self.locator is None:
- self.locator = ticker.MaxNLocator(N+1)
+ if self.logscale:
+ self.locator = ticker.LogLocator()
+ else:
+ self.locator = ticker.MaxNLocator(N+1)
locator = self.locator
zmax = self.zmax
zmin = self.zmin
@@ -503,7 +515,10 @@
if zmax >= lev[-1]:
lev[-1] += zmargin
if zmin <= lev[0]:
- lev[0] -= zmargin
+ if self.logscale:
+ lev[0] = 0.99 * zmin
+ else:
+ lev[0] -= zmargin
self._auto = True
if self.filled:
return lev
@@ -589,6 +604,10 @@
raise TypeError("Too many arguments to %s; see help(%s)" % (fn,fn))
self.zmax = ma.maximum(z)
self.zmin = ma.minimum(z)
+ if self.logscale and self.zmin <= 0:
+ z = ma.masked_where(z <= 0, z)
+ warnings.warn('Log scale: values of z <=0 have been masked')
+ self.zmin = z.min()
self._auto = False
if self.levels is None:
if Nargs == 1 or Nargs == 3:
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins