Skip to content

Commit 45d27c9

Browse files
authored
Merge pull request #17761 from QuLogic/update-artist-tutorial
Update hard-coded results in artist tutorial
2 parents 224e451 + 4d5a295 commit 45d27c9

File tree

1 file changed

+107
-45
lines changed

1 file changed

+107
-45
lines changed

tutorials/intermediate/artists.py

Lines changed: 107 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ class in the matplotlib API, and the one you will be working with most
9191
.. sourcecode:: ipython
9292
9393
In [101]: ax.lines[0]
94-
Out[101]: <matplotlib.lines.Line2D instance at 0x19a95710>
94+
Out[101]: <matplotlib.lines.Line2D at 0x19a95710>
9595
9696
In [102]: line
97-
Out[102]: <matplotlib.lines.Line2D instance at 0x19a95710>
97+
Out[102]: <matplotlib.lines.Line2D at 0x19a95710>
9898
9999
If you make subsequent calls to ``ax.plot`` (and the hold state is "on"
100100
which is the default) then additional lines will be added to the list.
@@ -107,7 +107,7 @@ class in the matplotlib API, and the one you will be working with most
107107
The Axes also has helper methods to configure and decorate the x-axis
108108
and y-axis tick, tick labels and axis labels::
109109
110-
xtext = ax.set_xlabel('my xdata') # returns a Text instance
110+
xtext = ax.set_xlabel('my xdata') # returns a Text instance
111111
ytext = ax.set_ylabel('my ydata')
112112
113113
When you call :meth:`ax.set_xlabel <matplotlib.axes.Axes.set_xlabel>`,
@@ -149,20 +149,20 @@ class in the matplotlib API, and the one you will be working with most
149149
# Customizing your objects
150150
# ========================
151151
#
152-
# Every element in the figure is represented by a matplotlib
152+
# Every element in the figure is represented by a Matplotlib
153153
# :class:`~matplotlib.artist.Artist`, and each has an extensive list of
154154
# properties to configure its appearance. The figure itself contains a
155155
# :class:`~matplotlib.patches.Rectangle` exactly the size of the figure,
156156
# which you can use to set the background color and transparency of the
157157
# figures. Likewise, each :class:`~matplotlib.axes.Axes` bounding box
158-
# (the standard white box with black edges in the typical matplotlib
158+
# (the standard white box with black edges in the typical Matplotlib
159159
# plot, has a ``Rectangle`` instance that determines the color,
160160
# transparency, and other properties of the Axes. These instances are
161161
# stored as member variables :attr:`Figure.patch
162162
# <matplotlib.figure.Figure.patch>` and :attr:`Axes.patch
163163
# <matplotlib.axes.Axes.patch>` ("Patch" is a name inherited from
164164
# MATLAB, and is a 2D "patch" of color on the figure, e.g., rectangles,
165-
# circles and polygons). Every matplotlib ``Artist`` has the following
165+
# circles and polygons). Every Matplotlib ``Artist`` has the following
166166
# properties
167167
#
168168
# ========== =================================================================
@@ -210,31 +210,49 @@ class in the matplotlib API, and the one you will be working with most
210210
# .. sourcecode:: ipython
211211
#
212212
# In [149]: matplotlib.artist.getp(fig.patch)
213-
# alpha = 1.0
214-
# animated = False
215-
# antialiased or aa = True
216-
# axes = None
217-
# clip_box = None
218-
# clip_on = False
219-
# clip_path = None
220-
# contains = None
221-
# edgecolor or ec = w
222-
# facecolor or fc = 0.75
223-
# figure = Figure(8.125x6.125)
224-
# fill = 1
225-
# hatch = None
226-
# height = 1
227-
# label =
228-
# linewidth or lw = 1.0
229-
# picker = None
230-
# transform = <Affine object at 0x134cca84>
231-
# verts = ((0, 0), (0, 1), (1, 1), (1, 0))
232-
# visible = True
233-
# width = 1
234-
# window_extent = <Bbox object at 0x134acbcc>
235-
# x = 0
236-
# y = 0
237-
# zorder = 1
213+
# agg_filter = None
214+
# alpha = None
215+
# animated = False
216+
# antialiased or aa = False
217+
# bbox = Bbox(x0=0.0, y0=0.0, x1=1.0, y1=1.0)
218+
# capstyle = butt
219+
# children = []
220+
# clip_box = None
221+
# clip_on = True
222+
# clip_path = None
223+
# contains = None
224+
# data_transform = BboxTransformTo( TransformedBbox( Bbox...
225+
# edgecolor or ec = (1.0, 1.0, 1.0, 1.0)
226+
# extents = Bbox(x0=0.0, y0=0.0, x1=640.0, y1=480.0)
227+
# facecolor or fc = (1.0, 1.0, 1.0, 1.0)
228+
# figure = Figure(640x480)
229+
# fill = True
230+
# gid = None
231+
# hatch = None
232+
# height = 1
233+
# in_layout = False
234+
# joinstyle = miter
235+
# label =
236+
# linestyle or ls = solid
237+
# linewidth or lw = 0.0
238+
# patch_transform = CompositeGenericTransform( BboxTransformTo( ...
239+
# path = Path(array([[0., 0.], [1., 0.], [1.,...
240+
# path_effects = []
241+
# picker = None
242+
# rasterized = None
243+
# sketch_params = None
244+
# snap = None
245+
# transform = CompositeGenericTransform( CompositeGenericTra...
246+
# transformed_clip_path_and_affine = (None, None)
247+
# url = None
248+
# verts = [[ 0. 0.] [640. 0.] [640. 480.] [ 0. 480....
249+
# visible = True
250+
# width = 1
251+
# window_extent = Bbox(x0=0.0, y0=0.0, x1=640.0, y1=480.0)
252+
# x = 0
253+
# xy = (0, 0)
254+
# y = 0
255+
# zorder = 1
238256
#
239257
# The docstrings for all of the classes also contain the ``Artist``
240258
# properties, so you can consult the interactive "help" or the
@@ -284,11 +302,10 @@ class in the matplotlib API, and the one you will be working with most
284302
# In [158]: ax2 = fig.add_axes([0.1, 0.1, 0.7, 0.3])
285303
#
286304
# In [159]: ax1
287-
# Out[159]: <matplotlib.axes.Subplot instance at 0xd54b26c>
305+
# Out[159]: <AxesSubplot:>
288306
#
289307
# In [160]: print(fig.axes)
290-
# [<matplotlib.axes.Subplot instance at 0xd54b26c>,
291-
# <matplotlib.axes.Axes instance at 0xd3f0b2c>]
308+
# [<AxesSubplot:>, <matplotlib.axes._axes.Axes object at 0x7f0768702be0>]
292309
#
293310
# Because the figure maintains the concept of the "current axes" (see
294311
# :meth:`Figure.gca <matplotlib.figure.Figure.gca>` and
@@ -354,7 +371,7 @@ class in the matplotlib API, and the one you will be working with most
354371
# Axes container
355372
# --------------
356373
#
357-
# The :class:`matplotlib.axes.Axes` is the center of the matplotlib
374+
# The :class:`matplotlib.axes.Axes` is the center of the Matplotlib
358375
# universe -- it contains the vast majority of all the ``Artists`` used
359376
# in a figure with many helper methods to create and add these
360377
# ``Artists`` to itself, as well as helper methods to access and
@@ -391,7 +408,7 @@ class in the matplotlib API, and the one you will be working with most
391408
# .. sourcecode:: ipython
392409
#
393410
# In [229]: print(ax.lines)
394-
# [<matplotlib.lines.Line2D instance at 0xd378b0c>]
411+
# [<matplotlib.lines.Line2D at 0xd378b0c>]
395412
#
396413
# Similarly, methods that create patches, like
397414
# :meth:`~matplotlib.axes.Axes.bar` creates a list of rectangles, will
@@ -403,9 +420,10 @@ class in the matplotlib API, and the one you will be working with most
403420
# In [233]: n, bins, rectangles = ax.hist(np.random.randn(1000), 50)
404421
#
405422
# In [234]: rectangles
406-
# Out[234]: <a list of 50 Patch objects>
423+
# Out[234]: <BarContainer object of 50 artists>
407424
#
408425
# In [235]: print(len(ax.patches))
426+
# Out[235]: 50
409427
#
410428
# You should not add objects directly to the ``Axes.lines`` or
411429
# ``Axes.patches`` lists unless you know exactly what you are doing,
@@ -433,8 +451,8 @@ class in the matplotlib API, and the one you will be working with most
433451
# None
434452
#
435453
# # and the transformation instance is set to the "identity transform"
436-
# In [265]: print(rect.get_transform())
437-
# <Affine object at 0x13695544>
454+
# In [265]: print(rect.get_data_transform())
455+
# IdentityTransform()
438456
#
439457
# # now we add the Rectangle to the Axes
440458
# In [266]: ax.add_patch(rect)
@@ -445,12 +463,56 @@ class in the matplotlib API, and the one you will be working with most
445463
# Axes(0.125,0.1;0.775x0.8)
446464
#
447465
# # and the transformation has been set too
448-
# In [268]: print(rect.get_transform())
449-
# <Affine object at 0x15009ca4>
466+
# In [268]: print(rect.get_data_transform())
467+
# CompositeGenericTransform(
468+
# TransformWrapper(
469+
# BlendedAffine2D(
470+
# IdentityTransform(),
471+
# IdentityTransform())),
472+
# CompositeGenericTransform(
473+
# BboxTransformFrom(
474+
# TransformedBbox(
475+
# Bbox(x0=0.0, y0=0.0, x1=1.0, y1=1.0),
476+
# TransformWrapper(
477+
# BlendedAffine2D(
478+
# IdentityTransform(),
479+
# IdentityTransform())))),
480+
# BboxTransformTo(
481+
# TransformedBbox(
482+
# Bbox(x0=0.125, y0=0.10999999999999999, x1=0.9, y1=0.88),
483+
# BboxTransformTo(
484+
# TransformedBbox(
485+
# Bbox(x0=0.0, y0=0.0, x1=6.4, y1=4.8),
486+
# Affine2D(
487+
# [[100. 0. 0.]
488+
# [ 0. 100. 0.]
489+
# [ 0. 0. 1.]])))))))
450490
#
451491
# # the default axes transformation is ax.transData
452492
# In [269]: print(ax.transData)
453-
# <Affine object at 0x15009ca4>
493+
# CompositeGenericTransform(
494+
# TransformWrapper(
495+
# BlendedAffine2D(
496+
# IdentityTransform(),
497+
# IdentityTransform())),
498+
# CompositeGenericTransform(
499+
# BboxTransformFrom(
500+
# TransformedBbox(
501+
# Bbox(x0=0.0, y0=0.0, x1=1.0, y1=1.0),
502+
# TransformWrapper(
503+
# BlendedAffine2D(
504+
# IdentityTransform(),
505+
# IdentityTransform())))),
506+
# BboxTransformTo(
507+
# TransformedBbox(
508+
# Bbox(x0=0.125, y0=0.10999999999999999, x1=0.9, y1=0.88),
509+
# BboxTransformTo(
510+
# TransformedBbox(
511+
# Bbox(x0=0.0, y0=0.0, x1=6.4, y1=4.8),
512+
# Affine2D(
513+
# [[100. 0. 0.]
514+
# [ 0. 100. 0.]
515+
# [ 0. 0. 1.]])))))))
454516
#
455517
# # notice that the xlimits of the Axes have not been changed
456518
# In [270]: print(ax.get_xlim())
@@ -463,12 +525,12 @@ class in the matplotlib API, and the one you will be working with most
463525
# # we can manually invoke the auto-scaling machinery
464526
# In [272]: ax.autoscale_view()
465527
#
466-
# # and now the xlim are updated to encompass the rectangle
528+
# # and now the xlim are updated to encompass the rectangle, plus margins
467529
# In [273]: print(ax.get_xlim())
468-
# (1.0, 6.0)
530+
# (0.75, 6.25)
469531
#
470532
# # we have to manually force a figure draw
471-
# In [274]: ax.figure.canvas.draw()
533+
# In [274]: fig.canvas.draw()
472534
#
473535
#
474536
# There are many, many ``Axes`` helper methods for creating primitive

0 commit comments

Comments
 (0)