From: <ef...@us...> - 2007-10-24 22:15:01
|
Revision: 3999 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3999&view=rev Author: efiring Date: 2007-10-24 15:14:57 -0700 (Wed, 24 Oct 2007) Log Message: ----------- Added ax kwarg to pyplot.colorbar and Figure.colorbar Modified Paths: -------------- trunk/matplotlib/API_CHANGES trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/colorbar.py trunk/matplotlib/lib/matplotlib/figure.py trunk/matplotlib/lib/matplotlib/pyplot.py Modified: trunk/matplotlib/API_CHANGES =================================================================== --- trunk/matplotlib/API_CHANGES 2007-10-24 19:42:49 UTC (rev 3998) +++ trunk/matplotlib/API_CHANGES 2007-10-24 22:14:57 UTC (rev 3999) @@ -1,6 +1,11 @@ - Changed cbook.reversed so it yields a tuple rather than a + Added ax kwarg to pyplot.colorbar and Figure.colorbar so that + one can specify the axes object from which space for the colorbar + is to be taken, if one does not want to make the colorbar axes + manually. + + Changed cbook.reversed so it yields a tuple rather than a (index, tuple). This agrees with the python reversed builtin, - and cbook only defines reversed if python doesnt provide the + and cbook only defines reversed if python doesnt provide the builtin. Made skiprows=1 the default on csv2rec Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007-10-24 19:42:49 UTC (rev 3998) +++ trunk/matplotlib/CHANGELOG 2007-10-24 22:14:57 UTC (rev 3999) @@ -1,3 +1,5 @@ +2007-10-24 Added ax kwarg to Figure.colorbar and pyplot.colorbar - EF + 2007-10-19 Removed a gsave/grestore pair surrounding _draw_ps, which was causing a loss graphics state info (see "EPS output problem - scatter & edgecolors" on mpl-dev, 2007-10-29) @@ -12,7 +14,7 @@ unit/ellipse_compare.py to compare spline with vertex approx for both aspects. JDH -2007-10-05 remove generator expressions from texmanager and mpltraits. +2007-10-05 remove generator expressions from texmanager and mpltraits. generator expressions are not supported by python-2.3 - DSD 2007-10-01 Made matplotlib.use() raise an exception if called after Modified: trunk/matplotlib/lib/matplotlib/colorbar.py =================================================================== --- trunk/matplotlib/lib/matplotlib/colorbar.py 2007-10-24 19:42:49 UTC (rev 3998) +++ trunk/matplotlib/lib/matplotlib/colorbar.py 2007-10-24 22:14:57 UTC (rev 3999) @@ -70,21 +70,27 @@ colorbar_doc = ''' Add a colorbar to a plot. -Function signatures: +Function signatures for the pyplot interface; all but the first are +also method signatures for the Figure.colorbar method: colorbar(**kwargs) - colorbar(mappable, **kwargs) + colorbar(mappable, cax=cax, **kwargs) + colorbar(mappable, ax=ax, **kwargs) - colorbar(mappable, cax, **kwargs) + arguments: + mappable: the image, ContourSet, etc. to which the colorbar applies; + this argument is mandatory for the Figure.colorbar + method but optional for the pyplot.colorbar function, + which sets the default to the current image. -The optional arguments mappable and cax may be included in the kwargs; -they are image, ContourSet, etc. to which the colorbar applies, and -the axes object in which the colorbar will be drawn. Defaults are -the current image and a new axes object created next to that image -after resizing the image. + keyword arguments: + cax: None | axes object into which the colorbar will be drawn + ax: None | parent axes object from which space for a new + colorbar axes will be stolen -kwargs are in two groups: + +**kwargs are in two groups: axes properties: %s colorbar properties: Modified: trunk/matplotlib/lib/matplotlib/figure.py =================================================================== --- trunk/matplotlib/lib/matplotlib/figure.py 2007-10-24 19:42:49 UTC (rev 3998) +++ trunk/matplotlib/lib/matplotlib/figure.py 2007-10-24 22:14:57 UTC (rev 3999) @@ -769,9 +769,9 @@ self.canvas.print_figure(*args, **kwargs) - def colorbar(self, mappable, cax=None, **kw): - orientation = kw.get('orientation', 'vertical') - ax = self.gca() + def colorbar(self, mappable, cax=None, ax=None, **kw): + if ax is None: + ax = self.gca() if cax is None: cax, kw = cbar.make_axes(ax, **kw) cb = cbar.Colorbar(cax, mappable, **kw) Modified: trunk/matplotlib/lib/matplotlib/pyplot.py =================================================================== --- trunk/matplotlib/lib/matplotlib/pyplot.py 2007-10-24 19:42:49 UTC (rev 3998) +++ trunk/matplotlib/lib/matplotlib/pyplot.py 2007-10-24 22:14:57 UTC (rev 3999) @@ -1080,10 +1080,10 @@ from matplotlib.colorbar import colorbar_doc -def colorbar(mappable = None, cax=None,**kw): +def colorbar(mappable=None, cax=None, ax=None, **kw): if mappable is None: mappable = gci() - ret = gcf().colorbar(mappable, cax = cax, **kw) + ret = gcf().colorbar(mappable, cax = cax, ax=ax, **kw) draw_if_interactive() return ret colorbar.__doc__ = colorbar_doc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |