Revision: 8278 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8278&view=rev Author: efiring Date: 2010-04-27 20:30:53 +0000 (Tue, 27 Apr 2010)
Log Message: ----------- contouring: fix various bugs Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/contour_image.py trunk/matplotlib/lib/matplotlib/contour.py trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py Modified: trunk/matplotlib/examples/pylab_examples/contour_image.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/contour_image.py 2010-04-27 19:39:27 UTC (rev 8277) +++ trunk/matplotlib/examples/pylab_examples/contour_image.py 2010-04-27 20:30:53 UTC (rev 8278) @@ -67,7 +67,7 @@ imshow(Z, extent=extent) v = axis() -contour(Z, cset3.levels, hold='on', colors = 'k', +contour(Z, levels, hold='on', colors = 'k', origin='upper', extent=extent) axis(v) title("Image, origin 'upper'") @@ -76,7 +76,7 @@ imshow(Z, origin='lower', extent=extent) v = axis() -contour(Z, cset3.levels, hold='on', colors = 'k', +contour(Z, levels, hold='on', colors = 'k', origin='lower', extent=extent) axis(v) title("Image, origin 'lower'") @@ -91,7 +91,7 @@ # domain that is contoured does not extend beyond these pixel centers. im = imshow(Z, interpolation='nearest', extent=extent) v = axis() -contour(Z, cset3.levels, hold='on', colors = 'k', +contour(Z, levels, hold='on', colors = 'k', origin='image', extent=extent) axis(v) ylim = get(gca(), 'ylim') Modified: trunk/matplotlib/lib/matplotlib/contour.py =================================================================== --- trunk/matplotlib/lib/matplotlib/contour.py 2010-04-27 19:39:27 UTC (rev 8277) +++ trunk/matplotlib/lib/matplotlib/contour.py 2010-04-27 20:30:53 UTC (rev 8278) @@ -147,7 +147,7 @@ if len(args) == 0: levels = self.levels - indices = range(len(self.levels)) + indices = range(len(levels)) elif len(args) == 1: levlabs = list(args[0]) indices, levels = [], [] @@ -674,7 +674,10 @@ self._process_levels() if self.colors is not None: - cmap = colors.ListedColormap(self.colors, N=len(self.layers)) + ncolors = len(self.levels) + if self.filled: + ncolors -= 1 + cmap = colors.ListedColormap(self.colors, N=ncolors) if self.filled: self.collections = cbook.silent_list('collections.PathCollection') else: @@ -772,7 +775,7 @@ havelimits = True if havelimits: self.ax.update_datalim([min, max]) - self.ax.autoscale_view() + self.ax.autoscale_view(tight=True) def _get_allsegs_and_allkinds(self): """ @@ -881,13 +884,15 @@ self.vmin = 2 * self.levels[0] - self.levels[1] if self.extend in ('both', 'max'): self.vmax = 2 * self.levels[-1] - self.levels[-2] - self.layers = self._levels # contour: a line is a thin layer if self.filled: self.layers = 0.5 * (self._levels[:-1] + self._levels[1:]) if self.extend in ('both', 'min'): self.layers[0] = 0.5 * (self.vmin + self._levels[1]) if self.extend in ('both', 'max'): self.layers[-1] = 0.5 * (self.vmax + self._levels[-2]) + else: + self.layers = self.levels # contour: a line is a thin layer + # Use only original levels--no extended levels def _process_colors(self): """ @@ -903,11 +908,13 @@ """ self.monochrome = self.cmap.monochrome if self.colors is not None: - i0, i1 = 0, len(self.layers) + i0, i1 = 0, len(self.levels) + if self.filled: + i1 -= 1 if self.extend in ('both', 'min'): i0 = -1 if self.extend in ('both', 'max'): - i1 = i1 + 1 + i1 += 1 self.cvalues = range(i0, i1) self.set_norm(colors.NoNorm()) else: @@ -944,8 +951,9 @@ tlinestyles = ['solid'] * Nlev if self.monochrome: neg_ls = mpl.rcParams['contour.negative_linestyle'] + eps = - (self.zmax - self.zmin) * 1e-15 for i, lev in enumerate(self.levels): - if lev < 0.0: + if lev < eps: tlinestyles[i] = neg_ls else: if cbook.is_string_like(linestyles): @@ -1073,6 +1081,8 @@ C = args[0].Cntr if self.levels is None: self.levels = args[0].levels + self.zmin = args[0].zmin + self.zmax = args[0].zmax else: x, y, z = self._contour_args(args, kwargs) @@ -1081,7 +1091,7 @@ y0 = ma.minimum(y) y1 = ma.maximum(y) self.ax.update_datalim([(x0,y0), (x1,y1)]) - self.ax.autoscale_view() + self.ax.autoscale_view(tight=True) _mask = ma.getmask(z) if _mask is ma.nomask: _mask = None Modified: trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py =================================================================== --- trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py 2010-04-27 19:39:27 UTC (rev 8277) +++ trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py 2010-04-27 20:30:53 UTC (rev 8278) @@ -201,7 +201,7 @@ # Let autoscale_view figure out how to use this data. self.autoscale_view() - def autoscale_view(self, scalex=True, scaley=True, scalez=True): + def autoscale_view(self, scalex=True, scaley=True, scalez=True, **kw): # This method looks at the rectanglular volume (see above) # of data and decides how to scale the view portal to fit it. @@ -284,19 +284,19 @@ if elev or azim are None (default), then the initial value is used which was specified in the :class:`Axes3D` constructor. """ - + self.dist = 10 - + if elev is None: self.elev = self.initial_elev else: self.elev = elev - + if azim is None: self.azim = self.initial_azim else: self.azim = azim - + def get_proj(self): """Create the projection matrix from the current viewing position. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins