Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite573c25

Browse files
committed
Merged revisions 3984-4000 via svnmerge from
http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib........ r3991 | efiring | 2007-10-23 17:25:24 -0400 (Tue, 23 Oct 2007) | 2 lines Bugfix: save colorbar axis label so it won't get lost........ r3999 | efiring | 2007-10-24 18:14:57 -0400 (Wed, 24 Oct 2007) | 2 lines Added ax kwarg to pyplot.colorbar and Figure.colorbar........svn path=/branches/transforms/; revision=4001
1 parent52d462f commite573c25

File tree

5 files changed

+45
-20
lines changed

5 files changed

+45
-20
lines changed

‎API_CHANGES

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
Changed cbook.reversed so it yields a tuple rather than a
1+
Added ax kwarg to pyplot.colorbar and Figure.colorbar so that
2+
one can specify the axes object from which space for the colorbar
3+
is to be taken, if one does not want to make the colorbar axes
4+
manually.
5+
6+
Changed cbook.reversed so it yields a tuple rather than a
27
(index, tuple). This agrees with the python reversed builtin,
3-
and cbook only defines reversed if python doesnt provide the
8+
and cbook only defines reversed if python doesnt provide the
49
builtin.
510

611
Made skiprows=1 the default on csv2rec

‎CHANGELOG

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2007-10-24 Added ax kwarg to Figure.colorbar and pyplot.colorbar - EF
2+
13
2007-10-19 Removed a gsave/grestore pair surrounding _draw_ps, which
24
was causing a loss graphics state info (see "EPS output
35
problem - scatter & edgecolors" on mpl-dev, 2007-10-29)
@@ -12,7 +14,7 @@
1214
unit/ellipse_compare.py to compare spline with vertex
1315
approx for both aspects. JDH
1416

15-
2007-10-05 remove generator expressions from texmanager and mpltraits.
17+
2007-10-05 remove generator expressions from texmanager and mpltraits.
1618
generator expressions are not supported by python-2.3 - DSD
1719

1820
2007-10-01 Made matplotlib.use() raise an exception if called after

‎lib/matplotlib/colorbar.py

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,27 @@
7070
colorbar_doc='''
7171
Add a colorbar to a plot.
7272
73-
Function signatures:
73+
Function signatures for the pyplot interface; all but the first are
74+
also method signatures for the Figure.colorbar method:
7475
7576
colorbar(**kwargs)
76-
7777
colorbar(mappable, **kwargs)
78+
colorbar(mappable, cax=cax, **kwargs)
79+
colorbar(mappable, ax=ax, **kwargs)
80+
81+
arguments:
82+
mappable: the image, ContourSet, etc. to which the colorbar applies;
83+
this argument is mandatory for the Figure.colorbar
84+
method but optional for the pyplot.colorbar function,
85+
which sets the default to the current image.
7886
79-
colorbar(mappable, cax, **kwargs)
87+
keyword arguments:
88+
cax: None | axes object into which the colorbar will be drawn
89+
ax: None | parent axes object from which space for a new
90+
colorbar axes will be stolen
8091
81-
The optional arguments mappable and cax may be included in the kwargs;
82-
they are image, ContourSet, etc. to which the colorbar applies, and
83-
the axes object in which the colorbar will be drawn. Defaults are
84-
the current image and a new axes object created next to that image
85-
after resizing the image.
8692
87-
kwargs are in two groups:
93+
**kwargs are in two groups:
8894
axes properties:
8995
%s
9096
colorbar properties:
@@ -155,6 +161,7 @@ def __init__(self, ax, cmap=None,
155161
self.filled=filled
156162
self.solids=None
157163
self.lines=None
164+
self.set_label('')
158165
ifcbook.iterable(ticks):
159166
self.locator=ticker.FixedLocator(ticks,nbins=len(ticks))
160167
else:
@@ -183,6 +190,7 @@ def draw_all(self):
183190
self._config_axes(X,Y)
184191
ifself.filled:
185192
self._add_solids(X,Y,C)
193+
self._set_label()
186194

187195
def_config_axes(self,X,Y):
188196
'''
@@ -220,11 +228,17 @@ def _config_axes(self, X, Y):
220228
ax.set_xticklabels(ticklabels)
221229
ax.xaxis.get_major_formatter().set_offset_string(offset_string)
222230

223-
defset_label(self,label,**kw):
231+
def_set_label(self):
224232
ifself.orientation=='vertical':
225-
self.ax.set_ylabel(label,**kw)
233+
self.ax.set_ylabel(self._label,**self._labelkw)
226234
else:
227-
self.ax.set_xlabel(label,**kw)
235+
self.ax.set_xlabel(self._label,**self._labelkw)
236+
237+
defset_label(self,label,**kw):
238+
self._label=label
239+
self._labelkw=kw
240+
self._set_label()
241+
228242

229243
def_outline(self,X,Y):
230244
'''
@@ -556,6 +570,10 @@ def notify(self, mappable):
556570
is changed.
557571
'''
558572
cm.ScalarMappable.notify(self,mappable)
573+
# We are using an ugly brute-force method: clearing and
574+
# redrawing the whole thing. The problem is that if any
575+
# properties have been changed by methods other than the
576+
# colorbar methods, those changes will be lost.
559577
self.ax.cla()
560578
self.draw_all()
561579
#if self.vmin != self.norm.vmin or self.vmax != self.norm.vmax:

‎lib/matplotlib/figure.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -790,9 +790,9 @@ def savefig(self, *args, **kwargs):
790790

791791
self.canvas.print_figure(*args,**kwargs)
792792

793-
defcolorbar(self,mappable,cax=None,**kw):
794-
orientation=kw.get('orientation','vertical')
795-
ax=self.gca()
793+
defcolorbar(self,mappable,cax=None,ax=None,**kw):
794+
ifaxisNone:
795+
ax=self.gca()
796796
ifcaxisNone:
797797
cax,kw=cbar.make_axes(ax,**kw)
798798
cb=cbar.Colorbar(cax,mappable,**kw)

‎lib/matplotlib/pyplot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,10 +1081,10 @@ def colormaps():
10811081

10821082

10831083
frommatplotlib.colorbarimportcolorbar_doc
1084-
defcolorbar(mappable=None,cax=None,**kw):
1084+
defcolorbar(mappable=None,cax=None,ax=None,**kw):
10851085
ifmappableisNone:
10861086
mappable=gci()
1087-
ret=gcf().colorbar(mappable,cax=cax,**kw)
1087+
ret=gcf().colorbar(mappable,cax=cax,ax=ax,**kw)
10881088
draw_if_interactive()
10891089
returnret
10901090
colorbar.__doc__=colorbar_doc

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp