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

Skip to content

DOC: Adding example references for API & Pyplots sections #11353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion examples/api/agg_oo_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
The object-oriented interface
=============================

A pure OO (look Ma, no pyplot!) example using the agg backend.
A pure object-oriented example using the agg backend. Notice that there is no
``pyplot`` used here.
"""

from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
Expand All @@ -21,3 +22,24 @@
ax.set_xlabel('time')
ax.set_ylabel('volts')
fig.savefig('test')

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods, classes and modules is shown
# in this example:

import matplotlib
matplotlib.backends.backend_agg.FigureCanvasAgg
matplotlib.figure.Figure
matplotlib.figure.Figure.add_subplot
matplotlib.figure.Figure.savefig
matplotlib.axes.Axes.plot
matplotlib.axes.Axes.set_title
matplotlib.axes.Axes.grid
matplotlib.axes.Axes.set_xlabel
matplotlib.axes.Axes.set_ylabel
15 changes: 15 additions & 0 deletions examples/api/filled_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,18 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None,
ax2.set_ylabel('x')

plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods, classes and modules is shown
# in this example:

import matplotlib
matplotlib.axes.Axes.fill_betweenx
matplotlib.axes.Axes.fill_between
matplotlib.axis.Axis.set_major_locator
15 changes: 15 additions & 0 deletions examples/api/font_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,18 @@
ax.set_xlabel('This is the default font')

plt.show()


#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods, classes and modules is shown
# in this example:

import matplotlib
matplotlib.font_manager.FontProperties
matplotlib.axes.Axes.set_title
51 changes: 48 additions & 3 deletions examples/api/histogram_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
the faster method of using PolyCollections, were implemented before we
had proper paths with moveto/lineto, closepoly etc in mpl. Now that
we have them, we can draw collections of regularly shaped objects with
homogeneous properties more efficiently with a PathCollection. This
example makes a histogram -- its more work to set up the vertex arrays
homogeneous properties more efficiently with a PathCollection. This
example makes a histogram -- it's more work to set up the vertex arrays
at the outset, but it should be much faster for large numbers of
objects
objects.
"""

import numpy as np
Expand Down Expand Up @@ -53,3 +53,48 @@
ax.set_ylim(bottom.min(), top.max())

plt.show()

#############################################################################
# It should be noted that instead of creating a three-dimensional array and
# using `~.path.Path.make_compound_path_from_polys`, we could as well create
# the compound path directly using vertices and codes as shown below

nrects = len(left)
nverts = nrects*(1+3+1)
verts = np.zeros((nverts, 2))
codes = np.ones(nverts, int) * path.Path.LINETO
codes[0::5] = path.Path.MOVETO
codes[4::5] = path.Path.CLOSEPOLY
verts[0::5,0] = left
verts[0::5,1] = bottom
verts[1::5,0] = left
verts[1::5,1] = top
verts[2::5,0] = right
verts[2::5,1] = top
verts[3::5,0] = right
verts[3::5,1] = bottom

barpath = path.Path(verts, codes)

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods, classes and modules is shown
# in this example:

import matplotlib
matplotlib.patches
matplotlib.patches.PathPatch
matplotlib.path
matplotlib.path.Path
matplotlib.path.Path.make_compound_path_from_polys
matplotlib.axes.Axes.add_patch
matplotlib.collections.PathCollection

# This example shows an alternative to
matplotlib.collections.PolyCollection
matplotlib.axes.Axes.hist
19 changes: 18 additions & 1 deletion examples/api/image_zcoord.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
==================================

Modify the coordinate formatter to report the image "z"
value of the nearest pixel given x and y
value of the nearest pixel given x and y.
This functionality is built in by default, but it
is still useful to show how to customize the
`~.axes.Axes.format_coord` function.
"""
import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -32,3 +35,17 @@ def format_coord(x, y):

ax.format_coord = format_coord
plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods, classes and modules is shown
# in this example:

import matplotlib
matplotlib.axes.Axes.format_coord
matplotlib.axes.Axes.imshow
14 changes: 14 additions & 0 deletions examples/api/joinstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,17 @@ def plot_angle(ax, x, y, angle, style):
ax.set_xlim(-.5, 2.75)
ax.set_ylim(-.5, 5.5)
plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods, classes and modules is shown
# in this example:

import matplotlib
matplotlib.axes.Axes.plot
matplotlib.pyplot.plot
16 changes: 16 additions & 0 deletions examples/api/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,19 @@
legend.get_frame().set_facecolor('#00FFCC')

plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods, classes and modules is shown
# in this example:

import matplotlib
matplotlib.axes.Axes.plot
matplotlib.pyplot.plot
matplotlib.axes.Axes.legend
matplotlib.pyplot.legend
31 changes: 28 additions & 3 deletions examples/api/line_with_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, *args, **kwargs):
lines.Line2D.__init__(self, *args, **kwargs)

# we can't access the label attr until *after* the line is
# inited
# initiated
self.text.set_text(self.get_label())

def set_figure(self, figure):
Expand Down Expand Up @@ -59,8 +59,33 @@ def draw(self, renderer):
line.text.set_color('red')
line.text.set_fontsize(16)


ax.add_line(line)


plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods, classes and modules is shown
# in this example:

import matplotlib
matplotlib.lines
matplotlib.lines.Line2D
matplotlib.lines.Line2D.set_data
matplotlib.artist
matplotlib.artist.Artist
matplotlib.artist.Artist.draw
matplotlib.artist.Artist.set_transform
matplotlib.text
matplotlib.text.Text
matplotlib.text.Text.set_color
matplotlib.text.Text.set_fontsize
matplotlib.text.Text.set_position
matplotlib.axes.Axes.add_line
matplotlib.transforms
matplotlib.transforms.Affine2D
17 changes: 17 additions & 0 deletions examples/api/mathtext_asarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,20 @@
fig.figimage(rgba2, 100, 300)

plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods, classes and modules is shown
# in this example:

import matplotlib
matplotlib.mathtext
matplotlib.mathtext.MathTextParser
matplotlib.mathtext.MathTextParser.to_png
matplotlib.mathtext.MathTextParser.to_rgba
matplotlib.figure.Figure.figimage
23 changes: 22 additions & 1 deletion examples/api/patch_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
Circles, Wedges and Polygons
============================

This example demonstrates how to use patch collections.
This example demonstrates how to use
:class:`patch collections<~.collections.PatchCollection>`.
"""

import numpy as np
Expand Down Expand Up @@ -56,3 +57,23 @@
fig.colorbar(p, ax=ax)

plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods, classes and modules is shown
# in this example:

import matplotlib
matplotlib.patches
matplotlib.patches.Circle
matplotlib.patches.Wedge
matplotlib.patches.Polygon
matplotlib.collections.PatchCollection
matplotlib.collections.Collection.set_array
matplotlib.axes.Axes.add_collection
matplotlib.figure.Figure.colorbar
16 changes: 16 additions & 0 deletions examples/api/power_norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,19 @@
fig.tight_layout()

plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods, classes and modules is shown
# in this example:

import matplotlib
matplotlib.colors
matplotlib.colors.PowerNorm
matplotlib.axes.Axes.hist2d
matplotlib.pyplot.hist2d
21 changes: 19 additions & 2 deletions examples/api/quad_bezier.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Bezier Curve
============

This example showcases the PathPatch object to create a Bezier polycurve path
patch.
This example showcases the `~.patches.PathPatch` object to create a Bezier
polycurve path patch.
"""

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

plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods, classes and modules is shown
# in this example:

import matplotlib
matplotlib.path
matplotlib.path.Path
matplotlib.patches
matplotlib.patches.PathPatch
matplotlib.axes.Axes.add_patch
21 changes: 21 additions & 0 deletions examples/api/radar_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,24 @@ def example_data():
size='large')

plt.show()


#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods, classes and modules is shown
# in this example:

import matplotlib
matplotlib.path
matplotlib.path.Path
matplotlib.spines
matplotlib.spines.Spine
matplotlib.projections
matplotlib.projections.polar
matplotlib.projections.polar.PolarAxes
matplotlib.projections.register_projection
Loading