From: <md...@us...> - 2007-11-15 15:13:45
|
Revision: 4302 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4302&view=rev Author: mdboom Date: 2007-11-15 07:13:38 -0800 (Thu, 15 Nov 2007) Log Message: ----------- Fix Subplot backward-incompatibility. Modified Paths: -------------- branches/transforms/lib/matplotlib/axes.py Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-11-15 14:59:53 UTC (rev 4301) +++ branches/transforms/lib/matplotlib/axes.py 2007-11-15 15:13:38 UTC (rev 4302) @@ -5465,6 +5465,7 @@ for label in self.get_yticklabels(): label.set_visible(firstcol) +_subplot_classes = {} def subplot_class_factory(axes_class=None): # This makes a new class that inherits from SubclassBase and the # given axes_class (which is assumed to be a subclass of Axes). @@ -5472,11 +5473,21 @@ # This is perhaps a little bit roundabout to make a new class on # the fly like this, but it means that a new Subplot class does # not have to be created for every type of Axes. - new_class = new.classobj("%sSubplot" % (axes_class.__name__), - (SubplotBase, axes_class), - {'_axes_class': axes_class}) + if axes_class is None: + axes_class = Axes + + new_class = _subplot_classes.get(axes_class) + if new_class is None: + new_class = new.classobj("%sSubplot" % (axes_class.__name__), + (SubplotBase, axes_class), + {'_axes_class': axes_class}) + _subplot_classes[axes_class] = new_class + return new_class - + +# This is provided for backward compatibility +Subplot = subplot_class_factory() + martist.kwdocd['Axes'] = martist.kwdocd['Subplot'] = martist.kwdoc(Axes) """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-20 13:17:55
|
Revision: 4388 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4388&view=rev Author: mdboom Date: 2007-11-20 05:14:34 -0800 (Tue, 20 Nov 2007) Log Message: ----------- Reverting imshow -- these issues are being dealt with by Eric Firing on the trunk. Modified Paths: -------------- branches/transforms/lib/matplotlib/axes.py Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-11-20 13:13:22 UTC (rev 4387) +++ branches/transforms/lib/matplotlib/axes.py 2007-11-20 13:14:34 UTC (rev 4388) @@ -4386,9 +4386,7 @@ #### plotting z(x,y): imshow, pcolor and relatives, contour - def imshow(self, I, - X = None, - Y = None, + def imshow(self, X, cmap = None, norm = None, aspect=None, @@ -4405,24 +4403,18 @@ **kwargs): """ - 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, cmap=None, norm=None, aspect=None, interpolation=None, + alpha=1.0, vmin=None, vmax=None, origin=None, extent=None) - IMSHOW(I) - plot image I to current axes, resampling to scale to axes - size (I may be numpy array or PIL image) + 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, 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 + IMSHOW(X, **kwargs) - Use keyword args to control image scaling, + colormapping etc. See below for details - 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 + 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 shapes: MxN : luminance (grayscale, float array only) @@ -4434,10 +4426,6 @@ 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: @@ -4502,24 +4490,11 @@ if cmap is not None: assert(isinstance(cmap, mcolors.Colormap)) if aspect is None: aspect = rcParams['image.aspect'] 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 = mimage.AxesImage(self, cmap, norm, interpolation, origin, extent, + filternorm=filternorm, + filterrad=filterrad, **kwargs) + + im.set_data(X) im.set_alpha(alpha) self._set_artist_props(im) im.set_clip_path(self.axesPatch) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-03 19:16:21
|
Revision: 4569 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4569&view=rev Author: mdboom Date: 2007-12-03 11:16:17 -0800 (Mon, 03 Dec 2007) Log Message: ----------- Fix exception when a particular contour doesn't exist. Modified Paths: -------------- branches/transforms/lib/matplotlib/axes.py Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-12-03 19:07:36 UTC (rev 4568) +++ branches/transforms/lib/matplotlib/axes.py 2007-12-03 19:16:17 UTC (rev 4569) @@ -1137,7 +1137,8 @@ self._set_artist_props(collection) collection.set_clip_path(self.axesPatch) if autolim: - self.update_datalim(collection.get_datalim(self.transData)) + if len(collection._paths): + self.update_datalim(collection.get_datalim(self.transData)) collection._remove_method = lambda h: self.collections.remove(h) def add_line(self, line): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-04 16:01:11
|
Revision: 4577 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4577&view=rev Author: mdboom Date: 2007-12-04 08:01:06 -0800 (Tue, 04 Dec 2007) Log Message: ----------- Fix bug when collection is empty. Modified Paths: -------------- branches/transforms/lib/matplotlib/axes.py Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-12-04 14:38:48 UTC (rev 4576) +++ branches/transforms/lib/matplotlib/axes.py 2007-12-04 16:01:06 UTC (rev 4577) @@ -21,6 +21,7 @@ from matplotlib import lines as mlines from matplotlib import mlab from matplotlib import patches as mpatches +from matplotlib import path as mpath from matplotlib import quiver as mquiver from matplotlib import scale as mscale from matplotlib import table as mtable @@ -770,13 +771,14 @@ self.grid(self._gridOn) props = font_manager.FontProperties(size=rcParams['axes.titlesize']) - self.title = mtext.Text( - x=0.5, y=1.02, text='', + self.titleOffsetTrans = mtransforms.Affine2D() + self.title = mtext.Text( + x=0.5, y=1.00, text='', fontproperties=props, verticalalignment='bottom', horizontalalignment='center', ) - self.title.set_transform(self.transAxes) + self.title.set_transform(self.transAxes + self.titleOffsetTrans) self.title.set_clip_box(None) self._set_artist_props(self.title) @@ -800,6 +802,8 @@ self.xaxis.set_clip_path(self.axesPatch) self.yaxis.set_clip_path(self.axesPatch) + self.titleOffsetTrans.clear() + def clear(self): 'clear the axes' self.cla() @@ -905,14 +909,14 @@ ysize = max(math.fabs(ymax-ymin), 1e-30) return ysize/xsize - def apply_aspect(self): + def apply_aspect(self, currentPosition): ''' Use self._aspect and self._adjustable to modify the axes box or the view limits. ''' aspect = self.get_aspect() if aspect == 'auto': - self.set_position( self._originalPosition , 'active') + self.set_position(currentPosition, 'active') return if aspect == 'equal': @@ -929,7 +933,7 @@ fig_aspect = figH/figW if self._adjustable == 'box': box_aspect = A * self.get_data_ratio() - pb = self._originalPosition.frozen() + pb = currentPosition.frozen() pb1 = pb.shrunk_to_aspect(box_aspect, pb, fig_aspect) self.set_position(pb1.anchored(self.get_anchor(), pb), 'active') return @@ -1289,25 +1293,48 @@ YL = ylocator.autoscale() self.set_ybound(YL) + def adjust_for_axis_text(self, renderer): + pad_pixels = rcParams['xtick.major.pad'] * self.figure.dpi / 72.0 + inverse_transFigure = self.figure.transFigure.inverted() + t_text, b_text = self.xaxis.get_text_heights(renderer) + l_text, r_text = self.yaxis.get_text_widths(renderer) + title_height = self.title.get_window_extent(renderer).height + title_height += pad_pixels * 2.0 + original_t_text = t_text + + ((l_text, t_text), + (r_text, b_text), + (dummy, title_height)) = inverse_transFigure.transform( + ((l_text, t_text), + (r_text, b_text), + (0.0, title_height))) + x0, y0, x1, y1 = self.get_position(True).extents + # Adjust the title + self.titleOffsetTrans.clear().translate( + 0, original_t_text + pad_pixels * 2.0) + return mtransforms.Bbox.from_extents( + x0 + l_text, y0 + b_text, x1 - r_text, + y1 - t_text - title_height) + #### Drawing def draw(self, renderer=None, inframe=False): "Draw everything (plot lines, axes, labels)" - if renderer is None: + if renderer is None: renderer = self._cachedRenderer if renderer is None: raise RuntimeError('No renderer defined') if not self.get_visible(): return renderer.open_group('axes') - self.apply_aspect() + currentPosition = self.adjust_for_axis_text(renderer) + self.apply_aspect(currentPosition) + if self.axison and self._frameon: self.axesPatch.draw(renderer) artists = [] - - if len(self.images)<=1 or renderer.option_image_nocomposite(): for im in self.images: im.draw(renderer) @@ -1319,7 +1346,6 @@ ims = [(im.make_image(mag),0,0) for im in self.images if im.get_visible()] - im = mimage.from_images(self.bbox.height*mag, self.bbox.width*mag, ims) @@ -1360,6 +1386,14 @@ a.draw(renderer) renderer.close_group('axes') + +# ### DEBUGGING +# gc = renderer.new_gc() +# gc.set_linewidth(2.0) +# x0, y0, x1, y1 = self.get_position(True).extents +# renderer.draw_path(gc, mpath.Path( +# [[x0, y0], [x0, y1], [x1, y1], [x1, y0], [x0, y0]]), +# self.figure.transFigure) self._cachedRenderer = renderer def draw_artist(self, a): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-04 16:06:30
|
Revision: 4578 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4578&view=rev Author: mdboom Date: 2007-12-04 08:06:20 -0800 (Tue, 04 Dec 2007) Log Message: ----------- Oops in last commit Modified Paths: -------------- branches/transforms/lib/matplotlib/axes.py Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-12-04 16:01:06 UTC (rev 4577) +++ branches/transforms/lib/matplotlib/axes.py 2007-12-04 16:06:20 UTC (rev 4578) @@ -21,7 +21,6 @@ from matplotlib import lines as mlines from matplotlib import mlab from matplotlib import patches as mpatches -from matplotlib import path as mpath from matplotlib import quiver as mquiver from matplotlib import scale as mscale from matplotlib import table as mtable @@ -771,14 +770,13 @@ self.grid(self._gridOn) props = font_manager.FontProperties(size=rcParams['axes.titlesize']) - self.titleOffsetTrans = mtransforms.Affine2D() - self.title = mtext.Text( - x=0.5, y=1.00, text='', + self.title = mtext.Text( + x=0.5, y=1.02, text='', fontproperties=props, verticalalignment='bottom', horizontalalignment='center', ) - self.title.set_transform(self.transAxes + self.titleOffsetTrans) + self.title.set_transform(self.transAxes) self.title.set_clip_box(None) self._set_artist_props(self.title) @@ -802,8 +800,6 @@ self.xaxis.set_clip_path(self.axesPatch) self.yaxis.set_clip_path(self.axesPatch) - self.titleOffsetTrans.clear() - def clear(self): 'clear the axes' self.cla() @@ -909,14 +905,14 @@ ysize = max(math.fabs(ymax-ymin), 1e-30) return ysize/xsize - def apply_aspect(self, currentPosition): + def apply_aspect(self): ''' Use self._aspect and self._adjustable to modify the axes box or the view limits. ''' aspect = self.get_aspect() if aspect == 'auto': - self.set_position(currentPosition, 'active') + self.set_position( self._originalPosition , 'active') return if aspect == 'equal': @@ -933,7 +929,7 @@ fig_aspect = figH/figW if self._adjustable == 'box': box_aspect = A * self.get_data_ratio() - pb = currentPosition.frozen() + pb = self._originalPosition.frozen() pb1 = pb.shrunk_to_aspect(box_aspect, pb, fig_aspect) self.set_position(pb1.anchored(self.get_anchor(), pb), 'active') return @@ -1141,7 +1137,7 @@ self._set_artist_props(collection) collection.set_clip_path(self.axesPatch) if autolim: - if len(collection._paths): + if collection._paths and len(collection._paths): self.update_datalim(collection.get_datalim(self.transData)) collection._remove_method = lambda h: self.collections.remove(h) @@ -1293,48 +1289,25 @@ YL = ylocator.autoscale() self.set_ybound(YL) - def adjust_for_axis_text(self, renderer): - pad_pixels = rcParams['xtick.major.pad'] * self.figure.dpi / 72.0 - inverse_transFigure = self.figure.transFigure.inverted() - t_text, b_text = self.xaxis.get_text_heights(renderer) - l_text, r_text = self.yaxis.get_text_widths(renderer) - title_height = self.title.get_window_extent(renderer).height - title_height += pad_pixels * 2.0 - original_t_text = t_text - - ((l_text, t_text), - (r_text, b_text), - (dummy, title_height)) = inverse_transFigure.transform( - ((l_text, t_text), - (r_text, b_text), - (0.0, title_height))) - x0, y0, x1, y1 = self.get_position(True).extents - # Adjust the title - self.titleOffsetTrans.clear().translate( - 0, original_t_text + pad_pixels * 2.0) - return mtransforms.Bbox.from_extents( - x0 + l_text, y0 + b_text, x1 - r_text, - y1 - t_text - title_height) - #### Drawing def draw(self, renderer=None, inframe=False): "Draw everything (plot lines, axes, labels)" - if renderer is None: + if renderer is None: renderer = self._cachedRenderer if renderer is None: raise RuntimeError('No renderer defined') if not self.get_visible(): return renderer.open_group('axes') + self.apply_aspect() - currentPosition = self.adjust_for_axis_text(renderer) - self.apply_aspect(currentPosition) - if self.axison and self._frameon: self.axesPatch.draw(renderer) artists = [] + + if len(self.images)<=1 or renderer.option_image_nocomposite(): for im in self.images: im.draw(renderer) @@ -1346,6 +1319,7 @@ ims = [(im.make_image(mag),0,0) for im in self.images if im.get_visible()] + im = mimage.from_images(self.bbox.height*mag, self.bbox.width*mag, ims) @@ -1386,14 +1360,6 @@ a.draw(renderer) renderer.close_group('axes') - -# ### DEBUGGING -# gc = renderer.new_gc() -# gc.set_linewidth(2.0) -# x0, y0, x1, y1 = self.get_position(True).extents -# renderer.draw_path(gc, mpath.Path( -# [[x0, y0], [x0, y1], [x1, y1], [x1, y0], [x0, y0]]), -# self.figure.transFigure) self._cachedRenderer = renderer def draw_artist(self, a): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-04 20:07:44
|
Revision: 4591 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4591&view=rev Author: mdboom Date: 2007-12-04 12:07:31 -0800 (Tue, 04 Dec 2007) Log Message: ----------- Bugfix for faceted pcolor-based quadmeshes. Modified Paths: -------------- branches/transforms/lib/matplotlib/axes.py Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-12-04 20:06:45 UTC (rev 4590) +++ branches/transforms/lib/matplotlib/axes.py 2007-12-04 20:07:31 UTC (rev 4591) @@ -4694,12 +4694,14 @@ if shading == 'faceted': - edgecolors = (0,0,0,1), + edgecolors = (0,0,0,1), + linewidths = (0.25,) else: edgecolors = 'None' + linewidths = (0.0,) kwargs.setdefault('edgecolors', edgecolors) kwargs.setdefault('antialiaseds', (0,)) - kwargs.setdefault('linewidths', (0.25,)) + kwargs.setdefault('linewidths', linewidths) collection = mcoll.PolyCollection(verts, **kwargs) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-04 20:55:17
|
Revision: 4600 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4600&view=rev Author: mdboom Date: 2007-12-04 12:55:04 -0800 (Tue, 04 Dec 2007) Log Message: ----------- Fix inverted x-axis bug. Modified Paths: -------------- branches/transforms/lib/matplotlib/axes.py Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-12-04 20:53:52 UTC (rev 4599) +++ branches/transforms/lib/matplotlib/axes.py 2007-12-04 20:55:04 UTC (rev 4600) @@ -1599,7 +1599,7 @@ if xmin is None: xmin = old_xmin if xmax is None: xmax = old_xmax - xmin, xmax = mtransforms.nonsingular(xmin, xmax) + xmin, xmax = mtransforms.nonsingular(xmin, xmax, increasing=False) xmin, xmax = self.xaxis.limit_range_for_scale(xmin, xmax) self.viewLim.intervalx = (xmin, xmax) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-06 13:37:32
|
Revision: 4641 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4641&view=rev Author: mdboom Date: 2007-12-06 05:37:29 -0800 (Thu, 06 Dec 2007) Log Message: ----------- Fix backward-compatibility breakage of apply_aspect. Modified Paths: -------------- branches/transforms/lib/matplotlib/axes.py Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-12-06 12:48:16 UTC (rev 4640) +++ branches/transforms/lib/matplotlib/axes.py 2007-12-06 13:37:29 UTC (rev 4641) @@ -909,11 +909,14 @@ ysize = max(math.fabs(ymax-ymin), 1e-30) return ysize/xsize - def apply_aspect(self, position): + def apply_aspect(self, position=None): ''' Use self._aspect and self._adjustable to modify the axes box or the view limits. ''' + if position is None: + position = self.get_position(True) + aspect = self.get_aspect() if aspect == 'auto': self.set_position( position , 'active') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-19 20:51:42
|
Revision: 4774 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4774&view=rev Author: mdboom Date: 2007-12-19 12:51:16 -0800 (Wed, 19 Dec 2007) Log Message: ----------- Fix aspect ratio bug. Modified Paths: -------------- branches/transforms/lib/matplotlib/axes.py Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-12-18 21:10:20 UTC (rev 4773) +++ branches/transforms/lib/matplotlib/axes.py 2007-12-19 20:51:16 UTC (rev 4774) @@ -1330,7 +1330,7 @@ if not self.get_visible(): return renderer.open_group('axes') - self.apply_aspect(self.get_position()) + self.apply_aspect(self.get_position(True)) if self.axison and self._frameon: self.axesPatch.draw(renderer) @@ -5079,7 +5079,7 @@ right """ - ax2 = self.figure.add_axes(self.get_position(), sharex=self, frameon=False) + ax2 = self.figure.add_axes(self.get_position(True), sharex=self, frameon=False) ax2.yaxis.tick_right() ax2.yaxis.set_label_position('right') self.yaxis.tick_left() @@ -5095,7 +5095,7 @@ top """ - ax2 = self.figure.add_axes(self.get_position(), sharey=self, frameon=False) + ax2 = self.figure.add_axes(self.get_position(True), sharey=self, frameon=False) ax2.xaxis.tick_top() ax2.xaxis.set_label_position('top') self.xaxis.tick_bottom() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |