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

Appearance settings

Commit f0e3fe7

Browse filesBrowse files
authored
Merge pull request #11353 from ImportanceOfBeingErnest/example-refs_api-etc
DOC: Adding example references for API & Pyplots sections
2 parents 391c0cb + cf20c4c commit f0e3fe7
Copy full SHA for f0e3fe7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

52 files changed

+905
-65
lines changed

‎examples/api/agg_oo_sgskip.py

Copy file name to clipboardExpand all lines: examples/api/agg_oo_sgskip.py
+23-1Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
The object-oriented interface
44
=============================
55
6-
A pure OO (look Ma, no pyplot!) example using the agg backend.
6+
A pure object-oriented example using the agg backend. Notice that there is no
7+
``pyplot`` used here.
78
"""
89

910
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
@@ -21,3 +22,24 @@
2122
ax.set_xlabel('time')
2223
ax.set_ylabel('volts')
2324
fig.savefig('test')
25+
26+
#############################################################################
27+
#
28+
# ------------
29+
#
30+
# References
31+
# """"""""""
32+
#
33+
# The use of the following functions, methods, classes and modules is shown
34+
# in this example:
35+
36+
import matplotlib
37+
matplotlib.backends.backend_agg.FigureCanvasAgg
38+
matplotlib.figure.Figure
39+
matplotlib.figure.Figure.add_subplot
40+
matplotlib.figure.Figure.savefig
41+
matplotlib.axes.Axes.plot
42+
matplotlib.axes.Axes.set_title
43+
matplotlib.axes.Axes.grid
44+
matplotlib.axes.Axes.set_xlabel
45+
matplotlib.axes.Axes.set_ylabel

‎examples/api/filled_step.py

Copy file name to clipboardExpand all lines: examples/api/filled_step.py
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,18 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None,
221221
ax2.set_ylabel('x')
222222

223223
plt.show()
224+
225+
#############################################################################
226+
#
227+
# ------------
228+
#
229+
# References
230+
# """"""""""
231+
#
232+
# The use of the following functions, methods, classes and modules is shown
233+
# in this example:
234+
235+
import matplotlib
236+
matplotlib.axes.Axes.fill_betweenx
237+
matplotlib.axes.Axes.fill_between
238+
matplotlib.axis.Axis.set_major_locator

‎examples/api/font_file.py

Copy file name to clipboardExpand all lines: examples/api/font_file.py
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,18 @@
2727
ax.set_xlabel('This is the default font')
2828

2929
plt.show()
30+
31+
32+
#############################################################################
33+
#
34+
# ------------
35+
#
36+
# References
37+
# """"""""""
38+
#
39+
# The use of the following functions, methods, classes and modules is shown
40+
# in this example:
41+
42+
import matplotlib
43+
matplotlib.font_manager.FontProperties
44+
matplotlib.axes.Axes.set_title

‎examples/api/histogram_path.py

Copy file name to clipboardExpand all lines: examples/api/histogram_path.py
+48-3Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
the faster method of using PolyCollections, were implemented before we
99
had proper paths with moveto/lineto, closepoly etc in mpl. Now that
1010
we have them, we can draw collections of regularly shaped objects with
11-
homogeneous properties more efficiently with a PathCollection. This
12-
example makes a histogram -- its more work to set up the vertex arrays
11+
homogeneous properties more efficiently with a PathCollection. This
12+
example makes a histogram -- it's more work to set up the vertex arrays
1313
at the outset, but it should be much faster for large numbers of
14-
objects
14+
objects.
1515
"""
1616

1717
import numpy as np
@@ -53,3 +53,48 @@
5353
ax.set_ylim(bottom.min(), top.max())
5454

5555
plt.show()
56+
57+
#############################################################################
58+
# It should be noted that instead of creating a three-dimensional array and
59+
# using `~.path.Path.make_compound_path_from_polys`, we could as well create
60+
# the compound path directly using vertices and codes as shown below
61+
62+
nrects = len(left)
63+
nverts = nrects*(1+3+1)
64+
verts = np.zeros((nverts, 2))
65+
codes = np.ones(nverts, int) * path.Path.LINETO
66+
codes[0::5] = path.Path.MOVETO
67+
codes[4::5] = path.Path.CLOSEPOLY
68+
verts[0::5,0] = left
69+
verts[0::5,1] = bottom
70+
verts[1::5,0] = left
71+
verts[1::5,1] = top
72+
verts[2::5,0] = right
73+
verts[2::5,1] = top
74+
verts[3::5,0] = right
75+
verts[3::5,1] = bottom
76+
77+
barpath = path.Path(verts, codes)
78+
79+
#############################################################################
80+
#
81+
# ------------
82+
#
83+
# References
84+
# """"""""""
85+
#
86+
# The use of the following functions, methods, classes and modules is shown
87+
# in this example:
88+
89+
import matplotlib
90+
matplotlib.patches
91+
matplotlib.patches.PathPatch
92+
matplotlib.path
93+
matplotlib.path.Path
94+
matplotlib.path.Path.make_compound_path_from_polys
95+
matplotlib.axes.Axes.add_patch
96+
matplotlib.collections.PathCollection
97+
98+
# This example shows an alternative to
99+
matplotlib.collections.PolyCollection
100+
matplotlib.axes.Axes.hist

‎examples/api/image_zcoord.py

Copy file name to clipboardExpand all lines: examples/api/image_zcoord.py
+18-1Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
==================================
55
66
Modify the coordinate formatter to report the image "z"
7-
value of the nearest pixel given x and y
7+
value of the nearest pixel given x and y.
8+
This functionality is built in by default, but it
9+
is still useful to show how to customize the
10+
`~.axes.Axes.format_coord` function.
811
"""
912
import numpy as np
1013
import matplotlib.pyplot as plt
@@ -32,3 +35,17 @@ def format_coord(x, y):
3235

3336
ax.format_coord = format_coord
3437
plt.show()
38+
39+
#############################################################################
40+
#
41+
# ------------
42+
#
43+
# References
44+
# """"""""""
45+
#
46+
# The use of the following functions, methods, classes and modules is shown
47+
# in this example:
48+
49+
import matplotlib
50+
matplotlib.axes.Axes.format_coord
51+
matplotlib.axes.Axes.imshow

‎examples/api/joinstyle.py

Copy file name to clipboardExpand all lines: examples/api/joinstyle.py
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,17 @@ def plot_angle(ax, x, y, angle, style):
3131
ax.set_xlim(-.5, 2.75)
3232
ax.set_ylim(-.5, 5.5)
3333
plt.show()
34+
35+
#############################################################################
36+
#
37+
# ------------
38+
#
39+
# References
40+
# """"""""""
41+
#
42+
# The use of the following functions, methods, classes and modules is shown
43+
# in this example:
44+
45+
import matplotlib
46+
matplotlib.axes.Axes.plot
47+
matplotlib.pyplot.plot

‎examples/api/legend.py

Copy file name to clipboardExpand all lines: examples/api/legend.py
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,19 @@
2727
legend.get_frame().set_facecolor('#00FFCC')
2828

2929
plt.show()
30+
31+
#############################################################################
32+
#
33+
# ------------
34+
#
35+
# References
36+
# """"""""""
37+
#
38+
# The use of the following functions, methods, classes and modules is shown
39+
# in this example:
40+
41+
import matplotlib
42+
matplotlib.axes.Axes.plot
43+
matplotlib.pyplot.plot
44+
matplotlib.axes.Axes.legend
45+
matplotlib.pyplot.legend

‎examples/api/line_with_text.py

Copy file name to clipboardExpand all lines: examples/api/line_with_text.py
+28-3Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(self, *args, **kwargs):
2020
lines.Line2D.__init__(self, *args, **kwargs)
2121

2222
# we can't access the label attr until *after* the line is
23-
# inited
23+
# initiated
2424
self.text.set_text(self.get_label())
2525

2626
def set_figure(self, figure):
@@ -59,8 +59,33 @@ def draw(self, renderer):
5959
line.text.set_color('red')
6060
line.text.set_fontsize(16)
6161

62-
6362
ax.add_line(line)
6463

65-
6664
plt.show()
65+
66+
#############################################################################
67+
#
68+
# ------------
69+
#
70+
# References
71+
# """"""""""
72+
#
73+
# The use of the following functions, methods, classes and modules is shown
74+
# in this example:
75+
76+
import matplotlib
77+
matplotlib.lines
78+
matplotlib.lines.Line2D
79+
matplotlib.lines.Line2D.set_data
80+
matplotlib.artist
81+
matplotlib.artist.Artist
82+
matplotlib.artist.Artist.draw
83+
matplotlib.artist.Artist.set_transform
84+
matplotlib.text
85+
matplotlib.text.Text
86+
matplotlib.text.Text.set_color
87+
matplotlib.text.Text.set_fontsize
88+
matplotlib.text.Text.set_position
89+
matplotlib.axes.Axes.add_line
90+
matplotlib.transforms
91+
matplotlib.transforms.Affine2D

‎examples/api/mathtext_asarray.py

Copy file name to clipboardExpand all lines: examples/api/mathtext_asarray.py
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,20 @@
2626
fig.figimage(rgba2, 100, 300)
2727

2828
plt.show()
29+
30+
#############################################################################
31+
#
32+
# ------------
33+
#
34+
# References
35+
# """"""""""
36+
#
37+
# The use of the following functions, methods, classes and modules is shown
38+
# in this example:
39+
40+
import matplotlib
41+
matplotlib.mathtext
42+
matplotlib.mathtext.MathTextParser
43+
matplotlib.mathtext.MathTextParser.to_png
44+
matplotlib.mathtext.MathTextParser.to_rgba
45+
matplotlib.figure.Figure.figimage

‎examples/api/patch_collection.py

Copy file name to clipboardExpand all lines: examples/api/patch_collection.py
+22-1Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
Circles, Wedges and Polygons
44
============================
55
6-
This example demonstrates how to use patch collections.
6+
This example demonstrates how to use
7+
:class:`patch collections<~.collections.PatchCollection>`.
78
"""
89

910
import numpy as np
@@ -56,3 +57,23 @@
5657
fig.colorbar(p, ax=ax)
5758

5859
plt.show()
60+
61+
#############################################################################
62+
#
63+
# ------------
64+
#
65+
# References
66+
# """"""""""
67+
#
68+
# The use of the following functions, methods, classes and modules is shown
69+
# in this example:
70+
71+
import matplotlib
72+
matplotlib.patches
73+
matplotlib.patches.Circle
74+
matplotlib.patches.Wedge
75+
matplotlib.patches.Polygon
76+
matplotlib.collections.PatchCollection
77+
matplotlib.collections.Collection.set_array
78+
matplotlib.axes.Axes.add_collection
79+
matplotlib.figure.Figure.colorbar

‎examples/api/power_norm.py

Copy file name to clipboardExpand all lines: examples/api/power_norm.py
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,19 @@
3232
fig.tight_layout()
3333

3434
plt.show()
35+
36+
#############################################################################
37+
#
38+
# ------------
39+
#
40+
# References
41+
# """"""""""
42+
#
43+
# The use of the following functions, methods, classes and modules is shown
44+
# in this example:
45+
46+
import matplotlib
47+
matplotlib.colors
48+
matplotlib.colors.PowerNorm
49+
matplotlib.axes.Axes.hist2d
50+
matplotlib.pyplot.hist2d

‎examples/api/quad_bezier.py

Copy file name to clipboardExpand all lines: examples/api/quad_bezier.py
+19-2Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
Bezier Curve
44
============
55
6-
This example showcases the PathPatch object to create a Bezier polycurve path
7-
patch.
6+
This example showcases the `~.patches.PathPatch` object to create a Bezier
7+
polycurve path patch.
88
"""
99

1010
import matplotlib.path as mpath
@@ -24,3 +24,20 @@
2424
ax.set_title('The red point should be on the path')
2525

2626
plt.show()
27+
28+
#############################################################################
29+
#
30+
# ------------
31+
#
32+
# References
33+
# """"""""""
34+
#
35+
# The use of the following functions, methods, classes and modules is shown
36+
# in this example:
37+
38+
import matplotlib
39+
matplotlib.path
40+
matplotlib.path.Path
41+
matplotlib.patches
42+
matplotlib.patches.PathPatch
43+
matplotlib.axes.Axes.add_patch

‎examples/api/radar_chart.py

Copy file name to clipboardExpand all lines: examples/api/radar_chart.py
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,24 @@ def example_data():
202202
size='large')
203203

204204
plt.show()
205+
206+
207+
#############################################################################
208+
#
209+
# ------------
210+
#
211+
# References
212+
# """"""""""
213+
#
214+
# The use of the following functions, methods, classes and modules is shown
215+
# in this example:
216+
217+
import matplotlib
218+
matplotlib.path
219+
matplotlib.path.Path
220+
matplotlib.spines
221+
matplotlib.spines.Spine
222+
matplotlib.projections
223+
matplotlib.projections.polar
224+
matplotlib.projections.polar.PolarAxes
225+
matplotlib.projections.register_projection

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.