From: <mme...@us...> - 2008-04-28 19:19:52
|
Revision: 5094 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5094&view=rev Author: mmetz_bn Date: 2008-04-28 12:17:31 -0700 (Mon, 28 Apr 2008) Log Message: ----------- npy usage Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-04-28 18:26:08 UTC (rev 5093) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-04-28 19:17:31 UTC (rev 5094) @@ -4519,14 +4519,13 @@ x = npy.log10(x) if yscale=='log': y = npy.log10(y) - xmin = min(x) - xmax = max(x) - ymin = min(y) - ymax = max(y) + xmin = npy.amin(x) + xmax = npy.amax(x) + ymin = npy.amin(y) + ymax = npy.amax(y) # In the x-direction, the hexagons exactly cover the region from # xmin to xmax. Need some padding to avoid roundoff errors. - width = xmax - xmin - padding = 1.e-9 * width + padding = 1.e-9 * (xmax - xmin) xmin -= padding xmax += padding sx = (xmax-xmin) / nx @@ -4551,21 +4550,22 @@ d1 = (x-ix1)**2 + 3.0 * (y-iy1)**2 d2 = (x-ix2-0.5)**2 + 3.0 * (y-iy2-0.5)**2 + bdist = (d1<d2) for i in xrange(len(x)): - if d1[i] < d2[i]: + if bdist[i]: lattice1[ix1[i], iy1[i]]+=1 else: lattice2[ix2[i], iy2[i]]+=1 px = xmin + sx * npy.array([ 0.5, 0.5, 0.0, -0.5, -0.5, 0.0]) - py = ymin + sy * npy.array([-0.5, 0.5 ,1.0, 0.5, -0.5, -1.0]) / 3.0 + py = ymin + sy * npy.array([-0.5, 0.5, 1.0, 0.5, -0.5, -1.0]) / 3.0 polygons = npy.zeros((6, n, 2), float) polygons[:,:nx1*ny1,0] = npy.repeat(npy.arange(nx1), ny1) - polygons[:,:nx1*ny1,1] = npy.array(range(ny1) * nx1) + polygons[:,:nx1*ny1,1] = npy.tile(npy.arange(ny1), nx1) polygons[:,nx1*ny1:,0] = npy.repeat(npy.arange(nx2) + 0.5, ny2) - polygons[:,nx1*ny1:,1] = npy.array(range(ny2) * nx2) + 0.5 + polygons[:,nx1*ny1:,1] = npy.tile(npy.arange(ny2), nx2) + 0.5 polygons = npy.transpose(polygons, axes=[1,0,2]) polygons[:,:,0] *= sx This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-15 18:54:38
|
Revision: 5141 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5141&view=rev Author: jdh2358 Date: 2008-05-15 11:54:23 -0700 (Thu, 15 May 2008) Log Message: ----------- fixed a problem with axh and vline scaling Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-05-15 13:03:49 UTC (rev 5140) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-05-15 18:54:23 UTC (rev 5141) @@ -2449,9 +2449,14 @@ %(Line2D)s """ + ymin, ymax = self.get_ylim() + if ymax<ymin: ymin, ymax = ymax, ymin + scaley = (y<ymin) or (y>ymax) + trans = mtransforms.blended_transform_factory( self.transAxes, self.transData) - l, = self.plot([xmin,xmax], [y,y], transform=trans, scalex=False, **kwargs) + l, = self.plot([xmin,xmax], [y,y], transform=trans, scalex=False, scaley=scaley, **kwargs) + return l axhline.__doc__ = cbook.dedent(axhline.__doc__) % martist.kwdocd @@ -2486,9 +2491,14 @@ %(Line2D)s """ + xmin, xmax = self.get_xlim() + if xmax<xmin: xmin, xmax = xmax, xmin + scalex = (x<xmin) or (x>xmax) + trans = mtransforms.blended_transform_factory( self.transData, self.transAxes) - l, = self.plot([x,x], [ymin,ymax] , transform=trans, scaley=False, **kwargs) + l, = self.plot([x,x], [ymin,ymax] , transform=trans, scalex=scalex, scaley=False, **kwargs) + return l axvline.__doc__ = cbook.dedent(axvline.__doc__) % martist.kwdocd This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mme...@us...> - 2008-05-16 17:07:02
|
Revision: 5148 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5148&view=rev Author: mmetz_bn Date: 2008-05-16 10:06:53 -0700 (Fri, 16 May 2008) Log Message: ----------- do not rely on equalwidth bin assumption for cumhist; trapz doesn't work correctly with new histogram semantic Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-05-16 14:52:15 UTC (rev 5147) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-05-16 17:06:53 UTC (rev 5148) @@ -5420,9 +5420,9 @@ bottom=None, histtype='bar', align='edge', orientation='vertical', width=None, log=False, **kwargs): """ - HIST(x, bins=10, normed=False, bottom=None, histtype='bar', - align='edge', orientation='vertical', width=None, - log=False, **kwargs) + HIST(x, bins=10, normed=False, cumulative=False, + bottom=None, histtype='bar', align='edge', + orientation='vertical', width=None, log=False, **kwargs) Compute the histogram of x. bins is either an integer number of bins or a sequence giving the bins. x are the data to be binned. @@ -5437,13 +5437,13 @@ # trapezoidal integration of the probability density function pdf, bins, patches = ax.hist(...) - print np.trapz(pdf, bins) + print np.sum(pdf * np.diff(bins)) - If cumulative is True then histogram is computed where each bin + If cumulative is True then a histogram is computed where each bin gives the counts in that bin plus all bins for smaller values. The last bins gives the total number of datapoints. If normed is also True then the histogram is normalized such that the last bin - equals one (assuming equally spaced bins). + equals one. histtype = 'bar' | 'step'. The type of histogram to draw. 'bar' is a traditional bar-type histogram, 'step' generates @@ -5469,10 +5469,10 @@ normed=bool(normed), new=True) if cumulative: - n = n.cumsum() if normed: - # normalize to 1 - n *= (bins[1]-bins[0]) + n = (n * np.diff(bins)).cumsum() + else: + n = n.cumsum() if histtype == 'bar': if width is None: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-05-23 18:06:37
|
Revision: 5232 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5232&view=rev Author: mdboom Date: 2008-05-23 11:05:27 -0700 (Fri, 23 May 2008) Log Message: ----------- Fix reST formatting in Axes.plot (as an opportunity to play with Darren's cool new toy) Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-05-23 17:41:58 UTC (rev 5231) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-05-23 18:05:27 UTC (rev 5232) @@ -2723,85 +2723,85 @@ def plot(self, *args, **kwargs): """ Plot lines and/or markers to the Axes. ``*args`` is a variable length - argument, allowing for multiple x,y pairs with an optional format - string. For example, each of the following is legal + argument, allowing for multiple *x*, *y* pairs with an optional format + string. For example, each of the following is legal:: - plot(x,y) # plot x and y using the default line style and color - plot(x,y, 'bo') # plot x and y using blue circle markers + plot(x, y) # plot x and y using the default line style and color + plot(x, y, 'bo') # plot x and y using blue circle markers plot(y) # plot y using x as index array 0..N-1 plot(y, 'r+') # ditto, but with red plusses - If x and/or y is 2-Dimensional, then the corresponding columns + If ``x`` and/or ``y`` is 2-dimensional, then the corresponding columns will be plotted. - An arbitrary number of x, y, fmt groups can be specified, as in + An arbitrary number of ``x``, ``y``, ``fmt`` groups can be specified, as in:: - a.plot(x1, y1, 'g^', x2, y2, 'g-') + a.plot(x1, y1, 'g^', x2, y2, 'g-') Return value is a list of lines that were added. - The following line styles are supported: + The following line styles are supported:: - * - : solid line - * -- : dashed line - * -. : dash-dot line - * : : dotted line - * . : points - * , : pixels - * o : circle symbols - * ^ : triangle up symbols - * v : triangle down symbols - * < : triangle left symbols - * > : triangle right symbols - * s : square symbols - * + : plus symbols - * x : cross symbols - * D : diamond symbols - * d : thin diamond symbols - * 1 : tripod down symbols - * 2 : tripod up symbols - * 3 : tripod left symbols - * 4 : tripod right symbols - * h : hexagon symbols - * H : rotated hexagon symbols - * p : pentagon symbols - * | : vertical line symbols - * _ : horizontal line symbols - * steps : use gnuplot style 'steps' # kwarg only + - # solid line + -- # dashed line + -. # dash-dot line + : # dotted line + . # points + , # pixels + o # circle symbols + ^ # triangle up symbols + v # triangle down symbols + < # triangle left symbols + > # triangle right symbols + s # square symbols + + # plus symbols + x # cross symbols + D # diamond symbols + d # thin diamond symbols + 1 # tripod down symbols + 2 # tripod up symbols + 3 # tripod left symbols + 4 # tripod right symbols + h # hexagon symbols + H # rotated hexagon symbols + p # pentagon symbols + | # vertical line symbols + _ # horizontal line symbols + steps # use gnuplot style 'steps' # kwarg only - The following color abbreviations are supported + The following color abbreviations are supported:: - b : blue - g : green - r : red - c : cyan - m : magenta - y : yellow - k : black - w : white + b # blue + g # green + r # red + c # cyan + m # magenta + y # yellow + k # black + w # white In addition, you can specify colors in many weird and - wonderful ways, including full names 'green', hex strings - '#008000', RGB or RGBA tuples (0,1,0,1) or grayscale - intensities as a string '0.8'. Of these, the string - specifications can be used in place of a fmt group, but the - tuple forms can be used only as kwargs. + wonderful ways, including full names (``'green'``), hex strings + (``'#008000'``), RGB or RGBA tuples (``(0,1,0,1)``) or grayscale + intensities as a string (``'0.8'``). Of these, the string + specifications can be used in place of a ``fmt`` group, but the + tuple forms can be used only as ``kwargs``. Line styles and colors are combined in a single format string, as in - 'bo' for blue circles. + ``'bo'`` for blue circles. The ``**kwargs`` can be used to set line properties (any property that has a ``set_*`` method). You can use this to set a line label (for auto legends), linewidth, anitialising, marker face color, etc. Here is an - example: + example:: plot([1,2,3], [1,2,3], 'go-', label='line 1', linewidth=2) plot([1,2,3], [1,4,9], 'rs', label='line 2') axis([0, 4, 0, 10]) legend() - If you make multiple lines with one plot command, the kwargs apply - to all those lines, eg + If you make multiple lines with one plot command, the ``kwargs`` apply + to all those lines, e.g.:: plot(x1, y1, x2, y2, antialised=False) @@ -2810,10 +2810,9 @@ The kwargs are Line2D properties: %(Line2D)s - kwargs scalex and scaley, if defined, are passed on - to autoscale_view to determine whether the x and y axes are - autoscaled; default True. See Axes.autoscale_view for more - information + kwargs ``scalex`` and ``scaley``, if defined, are passed on to + :meth:`autoscale_view` to determine whether the *x* and *y* axes + are autoscaled; the default is ``True``. """ scalex = kwargs.pop( 'scalex', True) scaley = kwargs.pop( 'scaley', True) @@ -5493,7 +5492,7 @@ n, bins = np.histogram(x, bins, range=None, normed=bool(normed), new=True) n = [n,] - + if cumulative: if normed: n = [(m * np.diff(bins)).cumsum() for m in n] @@ -5577,7 +5576,7 @@ patches.append( self.fill(x,y) ) else: raise ValueError, 'invalid histtype: %s' % histtype - + for patch in patches: for p in patch: p.update(kwargs) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-28 15:33:11
|
Revision: 5286 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5286&view=rev Author: jdh2358 Date: 2008-05-28 08:33:03 -0700 (Wed, 28 May 2008) Log Message: ----------- fixed an and/or bug in patch limits Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-05-28 14:39:23 UTC (rev 5285) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-05-28 15:33:03 UTC (rev 5286) @@ -1234,7 +1234,7 @@ # the bins, counts and patches lined up, but it throws off log # scaling. We'll ignore rects with zero height or width in # the auto-scaling - if isinstance(p, mpatches.Rectangle) and p.get_width()==0. or p.get_height()==0.: + if isinstance(p, mpatches.Rectangle) and p.get_width()==0. and p.get_height()==0.: return vertices = p.get_patch_transform().transform(p.get_path().vertices) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-05-28 17:00:44
|
Revision: 5291 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5291&view=rev Author: jdh2358 Date: 2008-05-28 10:00:15 -0700 (Wed, 28 May 2008) Log Message: ----------- fixed patch rect area zero bug -- finally! Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-05-28 16:51:39 UTC (rev 5290) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-05-28 17:00:15 UTC (rev 5291) @@ -1234,7 +1234,7 @@ # the bins, counts and patches lined up, but it throws off log # scaling. We'll ignore rects with zero height or width in # the auto-scaling - if isinstance(p, mpatches.Rectangle) and p.get_width()==0. and p.get_height()==0.: + if isinstance(p, mpatches.Rectangle) and (p.get_width()==0. or p.get_height()==0.): return vertices = p.get_patch_transform().transform(p.get_path().vertices) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2008-06-08 01:50:34
|
Revision: 5421 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5421&view=rev Author: efiring Date: 2008-06-07 18:50:33 -0700 (Sat, 07 Jun 2008) Log Message: ----------- Fix bug in handling "close" option of Axes.fill Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-06-08 01:49:09 UTC (rev 5420) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-06-08 01:50:33 UTC (rev 5421) @@ -353,7 +353,7 @@ if self.command == 'plot': func = makeline else: - closed = kwargs.pop("closed") + closed = kwargs.get('closed', True) func = makefill if multicol: for j in range(y.shape[1]): @@ -399,7 +399,7 @@ if self.command == 'plot': func = makeline else: - closed = kwargs.pop('closed') + closed = kwargs.get('closed', True) func = makefill if multicol: @@ -5812,7 +5812,7 @@ self.set_xscale('log') elif orientation == 'vertical': self.set_yscale('log') - + fill = False if histtype == 'stepfilled': fill = True @@ -5825,10 +5825,10 @@ x,y = y,x elif orientation != 'vertical': raise ValueError, 'invalid orientation: %s' % orientation - + color = self._get_lines._get_next_cycle_color() if fill: - patches.append( self.fill(x, y, + patches.append( self.fill(x, y, closed=False, facecolor=color) ) else: patches.append( self.fill(x, y, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-06-10 15:54:00
|
Revision: 5462 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5462&view=rev Author: jdh2358 Date: 2008-06-10 08:53:19 -0700 (Tue, 10 Jun 2008) Log Message: ----------- fixed auto-legend wart for bar and friends Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-06-10 15:50:55 UTC (rev 5461) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-06-10 15:53:19 UTC (rev 5462) @@ -5773,6 +5773,16 @@ #fig.savefig('histogram_demo',dpi=72) plt.show() + + You can use labels for your histogram, and only the first + Rectangle gets the label (the others get the magic string + '_nolegend_'. This will make the histograms work in the + intuitive way for bar charts:: + + ax.hist(10+2*np.random.randn(1000), label='men') + ax.hist(12+3*np.random.randn(1000), label='women', alpha=0.5) + ax.legend() + """ if not self._hold: self.cla() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-06-24 14:37:44
|
Revision: 5656 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5656&view=rev Author: jdh2358 Date: 2008-06-24 07:37:41 -0700 (Tue, 24 Jun 2008) Log Message: ----------- fixed a date autolocator refresh bug Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-06-24 13:56:55 UTC (rev 5655) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-06-24 14:37:41 UTC (rev 5656) @@ -2058,7 +2058,8 @@ *tz* is the time zone to use in labeling dates. Defaults to rc value. """ - if self.ignore_existing_data_limits: + xmin, xmax = self.dataLim.intervalx + if xmin==0.: # no data has been added - let's set the default datalim. # We should probably use a better proxy for the datalim # have been updated than the ignore setting @@ -2074,6 +2075,12 @@ locator = mdates.AutoDateLocator(tz) self.xaxis.set_major_locator(locator) + # the autolocator uses the viewlim to pick the right date + # locator, but it may not have correct viewlim before an + # autoscale. If the viewlim is still zero..1, set it to the + # datalim and the autoscaler will update it on request + if self.viewLim.intervalx[0]==0.: + self.viewLim.intervalx = tuple(self.dataLim.intervalx) locator.refresh() formatter = self.xaxis.get_major_formatter() @@ -2086,7 +2093,8 @@ *tz* is the time zone to use in labeling dates. Defaults to rc value. """ - if self.ignore_existing_data_limits: + ymin, ymax = self.dataLim.intervaly + if ymin==0.: # no data has been added - let's set the default datalim. # We should probably use a better proxy for the datalim # have been updated than the ignore setting @@ -2103,6 +2111,13 @@ if not isinstance(locator, mdates.DateLocator): locator = mdates.AutoDateLocator(tz) self.yaxis.set_major_locator(locator) + + # the autolocator uses the viewlim to pick the right date + # locator, but it may not have correct viewlim before an + # autoscale. If the viewlim is still zero..1, set it to the + # datalim and the autoscaler will update it on request + if self.viewLim.intervaly[0]==0.: + self.viewLim.intervaly = tuple(self.dataLim.intervaly) locator.refresh() formatter = self.xaxis.get_major_formatter() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-06-24 17:41:17
|
Revision: 5662 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5662&view=rev Author: mdboom Date: 2008-06-24 10:41:08 -0700 (Tue, 24 Jun 2008) Log Message: ----------- Docstring formatting fixes. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-06-24 17:36:44 UTC (rev 5661) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-06-24 17:41:08 UTC (rev 5662) @@ -4663,14 +4663,14 @@ *style*: the style of the regular symbol: - ===== ========================================= + ===== ============================================= Value Description - ===== ========================================= + ===== ============================================= 0 a regular polygon 1 a star-like symbol 2 an asterisk - 3 a circle (numsides and angle is ignored) - ===== ========================================= + 3 a circle (*numsides* and *angle* is ignored) + ===== ============================================= *angle*: the angle of rotation of the symbol This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-07-11 18:31:07
|
Revision: 5748 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5748&view=rev Author: mdboom Date: 2008-07-11 11:31:04 -0700 (Fri, 11 Jul 2008) Log Message: ----------- Typo in last commit Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-07-11 18:21:53 UTC (rev 5747) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-07-11 18:31:04 UTC (rev 5748) @@ -904,8 +904,8 @@ self.xaxis.set_clip_path(self.patch) self.yaxis.set_clip_path(self.patch) - self._shared_x_axes.clear() - self._shared_y_axes.clear() + self._shared_x_axes.clean() + self._shared_y_axes.clean() def clear(self): 'clear the axes' @@ -6032,7 +6032,7 @@ right """ - ax2 = self.figure.add_axes(self.get_position(True), sharex=self, + ax2 = self.figure.add_axes(self.get_position(True), # sharex=self, frameon=False) ax2.yaxis.tick_right() ax2.yaxis.set_label_position('right') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |