From: <ef...@us...> - 2007-11-14 18:10:05
|
Revision: 4278 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4278&view=rev Author: efiring Date: 2007-11-14 10:10:00 -0800 (Wed, 14 Nov 2007) Log Message: ----------- Use mpl standard import idiom in image.py Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/image.py Modified: trunk/matplotlib/lib/matplotlib/image.py =================================================================== --- trunk/matplotlib/lib/matplotlib/image.py 2007-11-14 18:08:07 UTC (rev 4277) +++ trunk/matplotlib/lib/matplotlib/image.py 2007-11-14 18:10:00 UTC (rev 4278) @@ -7,18 +7,23 @@ import sys, os import numpy as npy -import numerix.ma as ma +import matplotlib.numerix.npyma as ma + from matplotlib import rcParams -from artist import Artist -from colors import colorConverter -import cm -import _image +from matplotlib import artist as martist +from matplotlib import colors as mcolors +from matplotlib import cm +# For clarity, names from _image are given explicitly in this module: +from matplotlib import _image -from _image import * -class AxesImage(Artist, cm.ScalarMappable): +# For user convenience, the names from _image are also imported into +# the image namespace: +from matplotlib._image import * +class AxesImage(martist.Artist, cm.ScalarMappable): + def __init__(self, ax, cmap = None, norm = None, @@ -43,7 +48,7 @@ Additional kwargs are matplotlib.artist properties """ - Artist.__init__(self) + martist.Artist.__init__(self) cm.ScalarMappable.__init__(self, norm, cmap) if origin is None: origin = rcParams['image.origin'] @@ -101,7 +106,7 @@ ACCEPTS: float """ - Artist.set_alpha(self, alpha) + martist.Artist.set_alpha(self, alpha) self._imcache = None def changed(self): @@ -135,7 +140,8 @@ else: im = self._imcache - bg = colorConverter.to_rgba(self.axes.get_frame().get_facecolor(), 0) + fc = self.axes.get_frame().get_facecolor() + bg = mcolors.colorConverter.to_rgba(fc, 0) im.set_bg( *bg) # image input dimensions @@ -236,12 +242,12 @@ # by mistake. self.set_data(A) - + def set_extent(self, extent): """extent is data axes (left, right, bottom, top) for making image plots """ self._extent = extent - + xmin, xmax, ymin, ymax = extent corners = (xmin, ymin), (xmax, ymax) self.axes.update_datalim(corners) @@ -338,10 +344,9 @@ height *= magnification im = _image.pcolor(self._Ax, self._Ay, self._A, height, width, - (x0, x0+v_width, y0, y0+v_height), - ) - - bg = colorConverter.to_rgba(self.axes.get_frame().get_facecolor(), 0) + (x0, x0+v_width, y0, y0+v_height)) + fc = self.axes.get_frame().get_facecolor() + bg = mcolors.colorConverter.to_rgba(fc, 0) im.set_bg(*bg) return im @@ -408,7 +413,7 @@ -class FigureImage(Artist, cm.ScalarMappable): +class FigureImage(martist.Artist, cm.ScalarMappable): def __init__(self, fig, cmap = None, norm = None, @@ -422,7 +427,7 @@ norm is a colors.Normalize instance to map luminance to 0-1 """ - Artist.__init__(self) + martist.Artist.__init__(self) cm.ScalarMappable.__init__(self, norm, cmap) if origin is None: origin = rcParams['image.origin'] self.origin = origin @@ -470,7 +475,8 @@ x = self.to_rgba(self._A, self._alpha) im = _image.fromarray(x, 1) - im.set_bg( *colorConverter.to_rgba(self.figure.get_facecolor(), 0) ) + fc = self.figure.get_facecolor() + im.set_bg( *mcolors.colorConverter.to_rgba(fc, 0) ) im.is_grayscale = (self.cmap.name == "gray" and len(self._A.shape) == 2) if self.origin=='upper': This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-07 19:05:21
|
Revision: 4667 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4667&view=rev Author: mdboom Date: 2007-12-07 11:05:11 -0800 (Fri, 07 Dec 2007) Log Message: ----------- [ 1697287 ] imshow on log axes broken if axes limits != image extent Adds a warning when an image is used on non-linear axes. Doesn't really address the problem (see bug report for the reason.) Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/image.py Modified: trunk/matplotlib/lib/matplotlib/image.py =================================================================== --- trunk/matplotlib/lib/matplotlib/image.py 2007-12-07 18:22:30 UTC (rev 4666) +++ trunk/matplotlib/lib/matplotlib/image.py 2007-12-07 19:05:11 UTC (rev 4667) @@ -4,7 +4,7 @@ """ from __future__ import division -import sys, os +import sys, os, warnings import numpy as npy @@ -185,6 +185,9 @@ def draw(self, renderer, *args, **kwargs): if not self.get_visible(): return + if (self.axes.get_xscale() != 'linear' or + self.axes.get_yscale() != 'linear'): + warnings.warn("Images are not supported on non-linear axes.") im = self.make_image(renderer.get_image_magnification()) l, b, widthDisplay, heightDisplay = self.axes.bbox.get_bounds() renderer.draw_image(l, b, im, self.axes.bbox) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2008-01-09 01:27:37
|
Revision: 4827 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4827&view=rev Author: efiring Date: 2008-01-08 17:27:29 -0800 (Tue, 08 Jan 2008) Log Message: ----------- Update PcolorImage with transforms API changes Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/image.py Modified: trunk/matplotlib/lib/matplotlib/image.py =================================================================== --- trunk/matplotlib/lib/matplotlib/image.py 2008-01-08 22:13:08 UTC (rev 4826) +++ trunk/matplotlib/lib/matplotlib/image.py 2008-01-09 01:27:29 UTC (rev 4827) @@ -438,10 +438,8 @@ fc = self.axes.get_frame().get_facecolor() bg = mcolors.colorConverter.to_rgba(fc, 0) bg = (npy.array(bg)*255).astype(npy.uint8) - x0, y0, v_width, v_height = self.axes.viewLim.get_bounds() - l, b, width, height = self.axes.bbox.get_bounds() - width *= magnification - height *= magnification + width = self.axes.bbox.width * magnification + height = self.axes.bbox.height * magnification if self.check_update('array'): A = self.to_rgba(self._A, alpha=self._alpha, bytes=True) self._rgbacache = A @@ -449,9 +447,11 @@ self.is_grayscale = self.cmap.is_gray() else: A = self._rgbacache + vl = self.axes.viewLim im = _image.pcolor2(self._Ax, self._Ay, A, - height, width, - (x0, x0+v_width, y0, y0+v_height), + self.axes.bbox.height, + self.axes.bbox.width, + (vl.x0, vl.x1, vl.y0, vl.y1), bg) im.is_grayscale = self.is_grayscale return im @@ -459,8 +459,11 @@ def draw(self, renderer, *args, **kwargs): if not self.get_visible(): return im = self.make_image(renderer.get_image_magnification()) - l, b, widthDisplay, heightDisplay = self.axes.bbox.get_bounds() - renderer.draw_image(l, b, im, self.axes.bbox) + renderer.draw_image(self.axes.bbox.xmin, + self.axes.bbox.ymin, + im, + self.axes.bbox.frozen(), + *self.get_transformed_clip_path_and_affine()) def set_data(self, x, y, A): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-28 02:04:28
|
Revision: 5281 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5281&view=rev Author: jdh2358 Date: 2008-05-27 19:04:26 -0700 (Tue, 27 May 2008) Log Message: ----------- fixed rgbacache bug which broke clim and clam in interactive use Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/image.py Modified: trunk/matplotlib/lib/matplotlib/image.py =================================================================== --- trunk/matplotlib/lib/matplotlib/image.py 2008-05-27 21:21:32 UTC (rev 5280) +++ trunk/matplotlib/lib/matplotlib/image.py 2008-05-28 02:04:26 UTC (rev 5281) @@ -116,6 +116,7 @@ update state """ self._imcache = None + self._rgbacache = None cm.ScalarMappable.changed(self) @@ -424,7 +425,6 @@ raise NotImplementedError('Method not supported') def set_interpolation(self, s): - print s if s != None and s != 'nearest': raise NotImplementedError('Only nearest neighbor supported') AxesImage.set_interpolation(self, s) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-29 20:33:12
|
Revision: 5309 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5309&view=rev Author: jdh2358 Date: 2008-05-29 13:33:07 -0700 (Thu, 29 May 2008) Log Message: ----------- fixed an image bug Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/image.py Modified: trunk/matplotlib/lib/matplotlib/image.py =================================================================== --- trunk/matplotlib/lib/matplotlib/image.py 2008-05-29 20:29:54 UTC (rev 5308) +++ trunk/matplotlib/lib/matplotlib/image.py 2008-05-29 20:33:07 UTC (rev 5309) @@ -691,7 +691,7 @@ grayscale images, the return array is MxN. For RGB images, the return value is MxNx3. For RGBA images the return value is MxNx4 """ - def toarray(im) + def toarray(im): 'return a 1D array of floats' x_str = im.tostring('raw',im.mode,0,-1) x = np.fromstring(x_str,np.uint8) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2008-06-09 03:34:30
|
Revision: 5428 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5428&view=rev Author: efiring Date: 2008-06-08 20:34:24 -0700 (Sun, 08 Jun 2008) Log Message: ----------- Fix bug in imshow, introduced in r5042, found by A. Straw Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/image.py Modified: trunk/matplotlib/lib/matplotlib/image.py =================================================================== --- trunk/matplotlib/lib/matplotlib/image.py 2008-06-09 00:01:14 UTC (rev 5427) +++ trunk/matplotlib/lib/matplotlib/image.py 2008-06-09 03:34:24 UTC (rev 5428) @@ -170,7 +170,7 @@ if self._imcache is None: if self._A.dtype == np.uint8 and len(self._A.shape) == 3: - im = _image.frombyte(self._A[xslice,yslice,:], 0) + im = _image.frombyte(self._A[yslice,xslice,:], 0) im.is_grayscale = False else: if self._rgbacache is None: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |