From: <md...@us...> - 2008-06-05 17:06:18
|
Revision: 5402 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5402&view=rev Author: mdboom Date: 2008-06-05 10:06:16 -0700 (Thu, 05 Jun 2008) Log Message: ----------- Fix one-pixel space between images and axes border. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/image.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-06-05 16:17:57 UTC (rev 5401) +++ trunk/matplotlib/CHANGELOG 2008-06-05 17:06:16 UTC (rev 5402) @@ -1,3 +1,6 @@ +2008-06-05 Fix image drawing so there is no extra space to the right + or bottom - MGD + 2006-06-04 Added a figure title command subtitle as a Figure method and pyplot command -- see examples/figure_title.py - JDH Modified: trunk/matplotlib/lib/matplotlib/image.py =================================================================== --- trunk/matplotlib/lib/matplotlib/image.py 2008-06-05 16:17:57 UTC (rev 5401) +++ trunk/matplotlib/lib/matplotlib/image.py 2008-06-05 17:06:16 UTC (rev 5402) @@ -205,7 +205,9 @@ tx = (xmin-self.axes.viewLim.x0)/dxintv * numcols ty = (ymin-self.axes.viewLim.y0)/dyintv * numrows - l, b, widthDisplay, heightDisplay = self.axes.bbox.bounds + l, b, r, t = self.axes.bbox.extents + widthDisplay = (round(r) + 0.5) - (round(l) - 0.5) + heightDisplay = (round(t) + 0.5) - (round(b) - 0.5) widthDisplay *= magnification heightDisplay *= magnification im.apply_translation(tx, ty) @@ -226,7 +228,7 @@ 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.bounds - renderer.draw_image(l, b, im, self.axes.bbox.frozen(), + renderer.draw_image(round(l), round(b), im, self.axes.bbox.frozen(), *self.get_transformed_clip_path_and_affine()) def contains(self, mouseevent): @@ -378,7 +380,9 @@ raise RuntimeError('You must first set the image array') x0, y0, v_width, v_height = self.axes.viewLim.bounds - l, b, width, height = self.axes.bbox.bounds + l, b, r, t = self.axes.bbox.extents + width = (round(r) + 0.5) - (round(l) - 0.5) + height = (round(t) + 0.5) - (round(b) - 0.5) width *= magnification height *= magnification im = _image.pcolor(self._Ax, self._Ay, self._A, @@ -487,8 +491,11 @@ fc = self.axes.get_frame().get_facecolor() bg = mcolors.colorConverter.to_rgba(fc, 0) bg = (np.array(bg)*255).astype(np.uint8) - width = self.axes.bbox.width * magnification - height = self.axes.bbox.height * magnification + l, b, r, t = self.axes.bbox.extents + width = (round(r) + 0.5) - (round(l) - 0.5) + height = (round(t) + 0.5) - (round(b) - 0.5) + width = width * magnification + height = height * magnification if self.check_update('array'): A = self.to_rgba(self._A, alpha=self._alpha, bytes=True) self._rgbacache = A @@ -508,8 +515,8 @@ def draw(self, renderer, *args, **kwargs): if not self.get_visible(): return im = self.make_image(renderer.get_image_magnification()) - renderer.draw_image(self.axes.bbox.xmin, - self.axes.bbox.ymin, + renderer.draw_image(round(self.axes.bbox.xmin), + round(self.axes.bbox.ymin), im, self.axes.bbox.frozen(), *self.get_transformed_clip_path_and_affine()) @@ -638,7 +645,7 @@ def draw(self, renderer, *args, **kwargs): if not self.get_visible(): return im = self.make_image() - renderer.draw_image(self.ox, self.oy, im, self.figure.bbox, + renderer.draw_image(round(self.ox), round(self.oy), im, self.figure.bbox, *self.get_transformed_clip_path_and_affine()) def write_png(self, fname): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |