Skip to content

Commit 53b2575

Browse files
committed
Make Axes.add_artist etc. return their argument.
svn path=/trunk/matplotlib/; revision=7077
1 parent 74d9381 commit 53b2575

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
======================================================================
2+
2009-05-01 Changed add_artist and similar Axes methods to
3+
return their argument. - EF
24

35
2009-04-30 Incorrect eps bbox for landscape mode fixed - JJL
46

lib/matplotlib/axes.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1323,17 +1323,24 @@ def has_data(self):
13231323
len(self.patches))>0
13241324

13251325
def add_artist(self, a):
1326-
'Add any :class:`~matplotlib.artist.Artist` to the axes'
1326+
'''
1327+
Add any :class:`~matplotlib.artist.Artist` to the axes
1328+
1329+
Returns the artist.
1330+
'''
13271331
a.set_axes(self)
13281332
self.artists.append(a)
13291333
self._set_artist_props(a)
13301334
a.set_clip_path(self.patch)
13311335
a._remove_method = lambda h: self.artists.remove(h)
1336+
return a
13321337

13331338
def add_collection(self, collection, autolim=True):
13341339
'''
13351340
add a :class:`~matplotlib.collections.Collection` instance
13361341
to the axes
1342+
1343+
Returns the collection.
13371344
'''
13381345
label = collection.get_label()
13391346
if not label:
@@ -1348,11 +1355,14 @@ def add_collection(self, collection, autolim=True):
13481355
self.update_datalim(collection.get_datalim(self.transData))
13491356

13501357
collection._remove_method = lambda h: self.collections.remove(h)
1358+
return collection
13511359

13521360
def add_line(self, line):
13531361
'''
13541362
Add a :class:`~matplotlib.lines.Line2D` to the list of plot
13551363
lines
1364+
1365+
Returns the line.
13561366
'''
13571367
self._set_artist_props(line)
13581368
if line.get_clip_path() is None:
@@ -1363,6 +1373,7 @@ def add_line(self, line):
13631373
line.set_label('_line%d'%len(self.lines))
13641374
self.lines.append(line)
13651375
line._remove_method = lambda h: self.lines.remove(h)
1376+
return line
13661377

13671378
def _update_line_limits(self, line):
13681379
p = line.get_path()
@@ -1378,6 +1389,8 @@ def add_patch(self, p):
13781389
axes patches; the clipbox will be set to the Axes clipping
13791390
box. If the transform is not set, it will be set to
13801391
:attr:`transData`.
1392+
1393+
Returns the patch.
13811394
"""
13821395

13831396
self._set_artist_props(p)
@@ -1386,6 +1399,7 @@ def add_patch(self, p):
13861399
self._update_patch_limits(p)
13871400
self.patches.append(p)
13881401
p._remove_method = lambda h: self.patches.remove(h)
1402+
return p
13891403

13901404
def _update_patch_limits(self, patch):
13911405
'update the data limits for patch *p*'
@@ -1412,11 +1426,14 @@ def add_table(self, tab):
14121426
'''
14131427
Add a :class:`~matplotlib.tables.Table` instance to the
14141428
list of axes tables
1429+
1430+
Returns the table.
14151431
'''
14161432
self._set_artist_props(tab)
14171433
self.tables.append(tab)
14181434
tab.set_clip_path(self.patch)
14191435
tab._remove_method = lambda h: self.tables.remove(h)
1436+
return tab
14201437

14211438
def relim(self):
14221439
'recompute the data limits based on current artists'

0 commit comments

Comments
 (0)