Revision: 4189
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4189&view=rev
Author: mdboom
Date: 2007-11-09 11:09:42 -0800 (Fri, 09 Nov 2007)
Log Message:
-----------
Add support for nonuniform grids to imshow.
Modified Paths:
--------------
branches/transforms/lib/matplotlib/axes.py
branches/transforms/lib/matplotlib/image.py
Modified: branches/transforms/lib/matplotlib/axes.py
===================================================================
--- branches/transforms/lib/matplotlib/axes.py 2007-11-09 16:43:38 UTC (rev
4188)
+++ branches/transforms/lib/matplotlib/axes.py 2007-11-09 19:09:42 UTC (rev
4189)
@@ -4385,7 +4385,9 @@
#### plotting z(x,y): imshow, pcolor and relatives, contour
- def imshow(self, X,
+ def imshow(self, I,
+ X = None,
+ Y = None,
cmap = None,
norm = None,
aspect=None,
@@ -4402,18 +4404,24 @@
**kwargs):
"""
- IMSHOW(X, cmap=None, norm=None, aspect=None, interpolation=None,
- alpha=1.0, vmin=None, vmax=None, origin=None, extent=None)
+ IMSHOW(I, X=None, Y=None, cmap=None, norm=None, aspect=None,
+ interpolation=None, alpha=1.0, vmin=None, vmax=None,
+ origin=None, extent=None)
- IMSHOW(X) - plot image X to current axes, resampling to scale to axes
- size (X may be numarray/Numeric array or PIL image)
+ IMSHOW(I) - plot image I to current axes, resampling to scale to axes
+ size (I may be numarray/Numeric array or PIL image)
- IMSHOW(X, **kwargs) - Use keyword args to control image scaling,
- colormapping etc. See below for details
+ IMSHOW(I, X, Y) - plot image I to current axes, with
+ nonuniform X and Y axes. (I, X and Y may be
+ numarray/Numeric array or PIL image)
+
+ IMSHOW(I, X, Y, **kwargs) - Use keyword args to control image
+ scaling, colormapping etc. See
+ below for details
- Display the image in X to current axes. X may be a float array, a
- uint8 array or a PIL image. If X is an array, X can have the following
+ Display the image in I to current axes. I may be a float array, a
+ uint8 array or a PIL image. If I is an array, I can have the following
shapes:
MxN : luminance (grayscale, float array only)
@@ -4425,6 +4433,10 @@
The value for each component of MxNx3 and MxNx4 float arrays should be
in the range 0.0 to 1.0; MxN float arrays may be normalised.
+ X and/or Y may be provided to specify a non-uniform image
+ grid. Each element of the X or Y arrays is the width or height
+ of the corresponding pixel in the given image.
+
A image.AxesImage instance is returned
The following kwargs are allowed:
@@ -4488,12 +4500,25 @@
if norm is not None: assert(isinstance(norm, mcolors.Normalize))
if cmap is not None: assert(isinstance(cmap, mcolors.Colormap))
if aspect is None: aspect = rcParams['image.aspect']
- self.set_aspect(aspect)
- im = mimage.AxesImage(self, cmap, norm, interpolation, origin, extent,
- filternorm=filternorm,
- filterrad=filterrad, **kwargs)
-
- im.set_data(X)
+ # self.set_aspect(aspect)
+
+ if X is None and Y is None:
+ im = mimage.AxesImage(self, cmap, norm, interpolation, origin,
extent,
+ filternorm=filternorm,
+ filterrad=filterrad, **kwargs)
+
+ im.set_data(I)
+ else:
+ if X is None:
+ X = npy.arange(I.shape[1])
+ if Y is None:
+ Y = npy.arange(I.shape[0])
+ im = mimage.NonUniformImage(self, cmap=cmap, norm=norm,
+ interpolation=interpolation,
+ origin=origin, extent=extent,
+ filternorm=filternorm,
+ filterrad=filterrad, **kwargs)
+ im.set_data(X, Y, I)
im.set_alpha(alpha)
self._set_artist_props(im)
im.set_clip_path(self.axesPatch)
@@ -4515,7 +4540,7 @@
return im
-
+
def _pcolorargs(self, funcname, *args):
if len(args)==1:
C = args[0]
Modified: branches/transforms/lib/matplotlib/image.py
===================================================================
--- branches/transforms/lib/matplotlib/image.py 2007-11-09 16:43:38 UTC (rev
4188)
+++ branches/transforms/lib/matplotlib/image.py 2007-11-09 19:09:42 UTC (rev
4189)
@@ -77,8 +77,6 @@
# reverse interp dict
self._interpdr = dict([ (v,k) for k,v in self._interpd.items()])
- if interpolation is None: interpolation =
rcParams['image.interpolation']
-
self.set_interpolation(interpolation)
self.axes = ax
@@ -267,7 +265,7 @@
ACCEPTS: ['bicubic' | 'bilinear' | 'blackman100' | 'blackman256' |
'blackman64', 'nearest' | 'sinc144' | 'sinc256' | 'sinc64' | 'spline16' |
'spline36']
"""
-
+ if s is None: s = rcParams['image.interpolation']
s = s.lower()
if not self._interpd.has_key(s):
raise ValueError('Illegal interpolation string')
@@ -317,17 +315,10 @@
class NonUniformImage(AxesImage):
def __init__(self, ax,
- cmap = None,
- norm = None,
- extent=None,
+ **kwargs
):
AxesImage.__init__(self, ax,
- cmap = cmap,
- norm = norm,
- extent=extent,
- interpolation = 'nearest',
- origin = 'lower',
- )
+ **kwargs)
def make_image(self, magnification=1.0):
if self._A is None:
@@ -382,9 +373,11 @@
raise NotImplementedError('Method not supported')
def set_interpolation(self, s):
- if s != 'nearest':
+ print s
+ if s != None and s != 'nearest':
raise NotImplementedError('Only nearest neighbor supported')
-
+ AxesImage.set_interpolation(self, s)
+
def get_extent(self):
if self._A is None:
raise RuntimeError('Must set data first')
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