Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 40f24d5

Browse files
committed
renamed axesPatch, axesFrame and figurePatch to be less redundant
svn path=/trunk/matplotlib/; revision=5674
1 parent 5e8b1be commit 40f24d5

10 files changed

Lines changed: 94 additions & 74 deletions

File tree

API_CHANGES

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Changes for 0.98.x
2+
==================
3+
4+
* Figure.figurePatch renamed Figure.patch, Axes.axesPatch renamed
5+
Axes.patch, Axes.axesFrame renamed Axes.frame, Axes.get_frame, which
6+
returns Axes.patch, is deprecated. Examples and users guide updated
7+
18
Changes for 0.98.1
29
==================
310

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2008-06-25 Figure.figurePatch renamed Figure.patch, Axes.axesPatch
2+
renamed Axes.patch, Axes.axesFrame renamed Axes.frame,
3+
Axes.get_frame, which returns Axes.patch, is deprecated.
4+
Examples and users guide updated - JDH
5+
16
2008-06-25 Fix rendering quality of pcolor - MGD
27

38
=================================================================

doc/faq/howto_faq.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ backgrounds transparent when saving, but will not affect the displayed
1717
image on the screen. If you need finer grained control, eg you do not
1818
want full transparency or you to affect the screen displayed version
1919
as well, you can set the alpha properties directly. The figure has a
20-
:class:`matplotlib.patches.Rectangle` instance called *figurePatch*
21-
and the axes has a Rectangle instance called *axesPatch*. You can set
20+
:class:`matplotlib.patches.Rectangle` instance called *patch*
21+
and the axes has a Rectangle instance called *patch*. You can set
2222
any property on them directly (*facecolor*, *edgecolor*, *linewidth*,
2323
*linestyle*, *alpha*). Eg::
2424

2525
fig = plt.figure()
26-
fig.figurePatch.set_alpha(0.5)
26+
fig.patch.set_alpha(0.5)
2727
ax = fig.add_subplot(111)
28-
ax.axesPatch.set_alpha(0.5)
28+
ax.patch.set_alpha(0.5)
2929

3030
If you need *all* the figure elements to be transparent, there is
3131
currently no global alpha setting, but you can set the alpha channel

doc/pyplots/fig_axes_customize_simple.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
# plt.figure creates a matplotlib.figure.Figure instance
55
fig = plt.figure()
6-
rect = fig.figurePatch # a rectangle instance
6+
rect = fig.patch # a rectangle instance
77
rect.set_facecolor('lightgoldenrodyellow')
88

99
ax1 = fig.add_axes([0.1, 0.3, 0.4, 0.4])
10-
rect = ax1.axesPatch
10+
rect = ax1.patch
1111
rect.set_facecolor('lightslategray')
1212

1313

doc/users/artists.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ figures. Likewise, each :class:`~matplotlib.axes.Axes` bounding box
151151
(the standard white box with black edges in the typical matplotlib
152152
plot, has a ``Rectangle`` instance that determines the color,
153153
transparency, and other properties of the Axes. These instances are
154-
stored as member variables :attr:`Figure.figurePatch
155-
<matplotlib.figure.Figure.figurePatch>` and :attr:`Axes.axesPatch
156-
<matplotlib.axes.Axes.axesPatch>` ("Patch" is a name inherited from
154+
stored as member variables :attr:`Figure.patch
155+
<matplotlib.figure.Figure.patch>` and :attr:`Axes.patch
156+
<matplotlib.axes.Axes.patch>` ("Patch" is a name inherited from
157157
MATLAB™, and is a 2D "patch" of color on the figure, eg. rectangles,
158158
circles and polygons). Every matplotlib ``Artist`` has the following
159159
properties
@@ -199,7 +199,7 @@ properties mentioned above:
199199

200200
.. sourcecode:: ipython
201201

202-
In [149]: matplotlib.artist.getp(fig.figurePatch)
202+
In [149]: matplotlib.artist.getp(fig.patch)
203203
alpha = 1.0
204204
animated = False
205205
antialiased or aa = True
@@ -261,7 +261,7 @@ The top level container ``Artist`` is the
261261
:class:`matplotlib.figure.Figure`, and it contains everything in the
262262
figure. The background of the figure is a
263263
:class:`~matplotlib.patches.Rectangle` which is stored in
264-
:attr:`Figure.figurePatch <matplotlib.figure.Figure.figurePatch>`. As
264+
:attr:`Figure.patch <matplotlib.figure.Figure.patch>`. As
265265
you add subplots (:meth:`~matplotlib.figure.Figure.add_subplot`) and
266266
axes (:meth:`~matplotlib.figure.Figure.add_axes`) to the figure
267267
these will be appended to the :attr:`Figure.axes
@@ -336,7 +336,7 @@ Here is a summary of the Artists the figure contains
336336
Figure attribute Description
337337
================ ===============================================================
338338
axes A list of Axes instances (includes Subplot)
339-
figurePatch The Rectangle background
339+
patch The Rectangle background
340340
images A list of FigureImages patches - useful for raw pixel display
341341
legends A list of Figure Legend instances (different from Axes.legends)
342342
lines A list of Figure Line2D instances (rarely used, see Axes.lines)
@@ -356,13 +356,13 @@ in a figure with many helper methods to create and add these
356356
customize the ``Artists`` it contains. Like the
357357
:class:`~matplotlib.figure.Figure`, it contains a
358358
:class:`~matplotlib.patches.Patch`
359-
:attr:`~matplotlib.axes.Axes.axesPatch` which is a
359+
:attr:`~matplotlib.axes.Axes.patch` which is a
360360
:class:`~matplotlib.patches.Rectangle` for Cartesian coordinates and a
361361
:class:`~matplotlib.patches.Circle` for polar coordinates; this patch
362362
determines the shape, background and border of the plotting region::
363363

364364
ax = fig.add_subplot(111)
365-
rect = ax.axesPatch # a Rectangle instance
365+
rect = ax.patch # a Rectangle instance
366366
rect.set_facecolor('green')
367367

368368
When you call a plotting method, eg. the canonical
@@ -511,7 +511,7 @@ Below is a summary of the Artists that the Axes contains
511511
Axes attribute Description
512512
============== ======================================
513513
artists A list of Artist instances
514-
axesPatch Rectangle instance for Axes background
514+
patch Rectangle instance for Axes background
515515
collections A list of Collection instances
516516
images A list of AxesImage
517517
legends A list of Legend instances

examples/api/logo2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
figcolor = '#FFFFCC'
88
dpi = 80
99
fig = plt.figure(figsize=(8, 2),dpi=dpi)
10-
fig.figurePatch.set_edgecolor(figcolor)
11-
fig.figurePatch.set_facecolor(figcolor)
10+
fig.patch.set_edgecolor(figcolor)
11+
fig.patch.set_facecolor(figcolor)
1212

1313
# the polar bar plot
1414
ax = fig.add_axes([0.05, 0.05, 0.2, 01], polar=True)
15-
ax.axesPatch.set_alpha(axalpha)
15+
ax.patch.set_alpha(axalpha)
1616
N = 20
1717
theta = np.arange(0.0, 2*np.pi, 2*np.pi/N) + np.pi
1818
radii = 10*np.random.rand(N)
@@ -31,7 +31,7 @@
3131

3232
# the histogram
3333
axhist = fig.add_axes([0.275, 0.075, 0.2, 0.4])
34-
axhist.axesPatch.set_alpha(axalpha)
34+
axhist.patch.set_alpha(axalpha)
3535
mu, sigma = 100, 15
3636
x = mu + sigma*np.random.randn(10000)
3737

examples/pylab_examples/set_and_get.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@
8383
getp(l1)
8484

8585
print 'Rectangle setters'
86-
setp(gca().axesPatch)
86+
setp(gca().patch)
8787
print 'Rectangle getters'
88-
getp(gca().axesPatch)
88+
getp(gca().patch)
8989

9090
t = title('Hi mom')
9191
print 'Text setters'

lib/matplotlib/axes.py

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ def _set_artist_props(self, a):
815815
a.set_transform(self.transData)
816816
a.axes = self
817817

818-
def get_axes_patch(self):
818+
def _gen_axes_patch(self):
819819
"""
820820
Returns the patch used to draw the background of the axes. It
821821
is also used as the clipping path for any data elements on the
@@ -878,24 +878,30 @@ def cla(self):
878878

879879
self._set_artist_props(self.title)
880880

881-
self.axesPatch = self.get_axes_patch()
882-
self.axesPatch.set_figure(self.figure)
883-
self.axesPatch.set_facecolor(self._axisbg)
884-
self.axesPatch.set_edgecolor(rcParams['axes.edgecolor'])
885-
self.axesPatch.set_linewidth(rcParams['axes.linewidth'])
886-
self.axesPatch.set_transform(self.transAxes)
887-
888-
self.axesFrame = self.get_axes_patch()
889-
self.axesFrame.set_figure(self.figure)
890-
self.axesFrame.set_facecolor('none')
891-
self.axesFrame.set_edgecolor(rcParams['axes.edgecolor'])
892-
self.axesFrame.set_linewidth(rcParams['axes.linewidth'])
893-
self.axesFrame.set_transform(self.transAxes)
894-
self.axesFrame.set_zorder(2.5)
881+
# the patch draws the background of the axes. we want this to
882+
# be below the other artists; the axesPatch name is deprecated
883+
self.patch = self.axesPatch = self._gen_axes_patch()
884+
self.patch.set_figure(self.figure)
885+
self.patch.set_facecolor(self._axisbg)
886+
self.patch.set_edgecolor(rcParams['axes.edgecolor'])
887+
self.patch.set_linewidth(rcParams['axes.linewidth'])
888+
self.patch.set_transform(self.transAxes)
889+
890+
# the frame draws the border around the axes and we want this
891+
# above. this is a place holder for a more sophisticated
892+
# artist that might just draw a left, bottom frame, or a
893+
# centered frame, etc the axesFrame name is deprecated
894+
self.frame = self.axesFrame = self._gen_axes_patch()
895+
self.frame.set_figure(self.figure)
896+
self.frame.set_facecolor('none')
897+
self.frame.set_edgecolor(rcParams['axes.edgecolor'])
898+
self.frame.set_linewidth(rcParams['axes.linewidth'])
899+
self.frame.set_transform(self.transAxes)
900+
self.frame.set_zorder(2.5)
895901
self.axison = True
896902

897-
self.xaxis.set_clip_path(self.axesPatch)
898-
self.yaxis.set_clip_path(self.axesPatch)
903+
self.xaxis.set_clip_path(self.patch)
904+
self.yaxis.set_clip_path(self.patch)
899905

900906

901907
def clear(self):
@@ -1211,7 +1217,8 @@ def get_child_artists(self):
12111217

12121218
def get_frame(self):
12131219
'Return the axes Rectangle frame'
1214-
return self.axesPatch
1220+
warnings.warn('use ax.patch instead', DeprecationWarning)
1221+
return self.patch
12151222

12161223
def get_legend(self):
12171224
'Return the legend.Legend instance, or None if no legend is defined'
@@ -1271,7 +1278,7 @@ def add_artist(self, a):
12711278
a.set_axes(self)
12721279
self.artists.append(a)
12731280
self._set_artist_props(a)
1274-
a.set_clip_path(self.axesPatch)
1281+
a.set_clip_path(self.patch)
12751282
a._remove_method = lambda h: self.artists.remove(h)
12761283

12771284
def add_collection(self, collection, autolim=True):
@@ -1284,7 +1291,7 @@ def add_collection(self, collection, autolim=True):
12841291
collection.set_label('collection%d'%len(self.collections))
12851292
self.collections.append(collection)
12861293
self._set_artist_props(collection)
1287-
collection.set_clip_path(self.axesPatch)
1294+
collection.set_clip_path(self.patch)
12881295
if autolim:
12891296
if collection._paths and len(collection._paths):
12901297
self.update_datalim(collection.get_datalim(self.transData))
@@ -1296,7 +1303,7 @@ def add_line(self, line):
12961303
lines
12971304
'''
12981305
self._set_artist_props(line)
1299-
line.set_clip_path(self.axesPatch)
1306+
line.set_clip_path(self.patch)
13001307

13011308
self._update_line_limits(line)
13021309
if not line.get_label():
@@ -1317,7 +1324,7 @@ def add_patch(self, p):
13171324
"""
13181325

13191326
self._set_artist_props(p)
1320-
p.set_clip_path(self.axesPatch)
1327+
p.set_clip_path(self.patch)
13211328
self._update_patch_limits(p)
13221329
self.patches.append(p)
13231330
p._remove_method = lambda h: self.patches.remove(h)
@@ -1345,7 +1352,7 @@ def add_table(self, tab):
13451352
'''
13461353
self._set_artist_props(tab)
13471354
self.tables.append(tab)
1348-
tab.set_clip_path(self.axesPatch)
1355+
tab.set_clip_path(self.patch)
13491356
tab._remove_method = lambda h: self.tables.remove(h)
13501357

13511358
def relim(self):
@@ -1419,7 +1426,7 @@ def in_axes(self, mouseevent):
14191426
return *True* if the given *mouseevent* (in display coords)
14201427
is in the Axes
14211428
'''
1422-
return self.axesPatch.contains(mouseevent)[0]
1429+
return self.patch.contains(mouseevent)[0]
14231430

14241431
def get_autoscale_on(self):
14251432
"""
@@ -1475,7 +1482,7 @@ def draw(self, renderer=None, inframe=False):
14751482
self.apply_aspect(self.get_position(True))
14761483

14771484
if self.axison and self._frameon:
1478-
self.axesPatch.draw(renderer)
1485+
self.patch.draw(renderer)
14791486

14801487
artists = []
14811488

@@ -1508,8 +1515,8 @@ def draw(self, renderer=None, inframe=False):
15081515
# respect z-order for now
15091516
renderer.draw_image(
15101517
round(l), round(b), im, self.bbox,
1511-
self.axesPatch.get_path(),
1512-
self.axesPatch.get_transform())
1518+
self.patch.get_path(),
1519+
self.patch.get_transform())
15131520

15141521
artists.extend(self.collections)
15151522
artists.extend(self.patches)
@@ -1529,7 +1536,7 @@ def draw(self, renderer=None, inframe=False):
15291536
if self.legend_ is not None:
15301537
artists.append(self.legend_)
15311538
if self.axison and self._frameon:
1532-
artists.append(self.axesFrame)
1539+
artists.append(self.frame)
15331540

15341541
dsu = [ (a.zorder, i, a) for i, a in enumerate(artists)
15351542
if not a.get_animated() ]
@@ -1696,7 +1703,7 @@ def set_axis_bgcolor(self, color):
16961703
"""
16971704

16981705
self._axisbg = color
1699-
self.axesPatch.set_facecolor(color)
1706+
self.patch.set_facecolor(color)
17001707

17011708
### data limits, ticks, tick labels, and formatting
17021709

@@ -2364,8 +2371,8 @@ def get_children(self):
23642371
children.append(self.legend_)
23652372
children.extend(self.collections)
23662373
children.append(self.title)
2367-
children.append(self.axesPatch)
2368-
children.append(self.axesFrame)
2374+
children.append(self.patch)
2375+
children.append(self.frame)
23692376
return children
23702377

23712378
def contains(self,mouseevent):
@@ -2375,7 +2382,7 @@ def contains(self,mouseevent):
23752382
"""
23762383
if callable(self._contains): return self._contains(self,mouseevent)
23772384

2378-
inside = self.axesPatch.contains(mouseevent.x, mouseevent.y)
2385+
inside = self.patch.contains(mouseevent.x, mouseevent.y)
23792386
return inside,{}
23802387

23812388
def pick(self, *args):
@@ -2647,7 +2654,7 @@ def annotate(self, *args, **kwargs):
26472654
a = mtext.Annotation(*args, **kwargs)
26482655
a.set_transform(mtransforms.IdentityTransform())
26492656
self._set_artist_props(a)
2650-
if kwargs.has_key('clip_on'): a.set_clip_path(self.axesPatch)
2657+
if kwargs.has_key('clip_on'): a.set_clip_path(self.patch)
26512658
self.texts.append(a)
26522659
return a
26532660
annotate.__doc__ = cbook.dedent(annotate.__doc__) % martist.kwdocd
@@ -5342,7 +5349,7 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
53425349
im.set_data(X)
53435350
im.set_alpha(alpha)
53445351
self._set_artist_props(im)
5345-
im.set_clip_path(self.axesPatch)
5352+
im.set_clip_path(self.patch)
53465353
#if norm is None and shape is None:
53475354
# im.set_clim(vmin, vmax)
53485355
if vmin is not None or vmax is not None:

0 commit comments

Comments
 (0)