Skip to content

Commit a429b4d

Browse files
authored
Merge pull request #15983 from anntzer/classless
DOC: Fix some examples docstrings.
2 parents 612aa5c + bda5d20 commit a429b4d

File tree

13 files changed

+59
-68
lines changed

13 files changed

+59
-68
lines changed

examples/images_contours_and_fields/affine_image.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
============================
55
66
7-
Prepending an affine transformation (:class:`~.transforms.Affine2D`)
8-
to the :ref:`data transform <data-coords>`
9-
of an image allows to manipulate the image's shape and orientation.
10-
This is an example of the concept of
11-
:ref:`transform chaining <transformation-pipeline>`.
12-
13-
For the backends that support draw_image with optional affine
14-
transform (e.g., agg, ps backend), the image of the output should
15-
have its boundary match the dashed yellow rectangle.
7+
Prepending an affine transformation (`~.transforms.Affine2D`) to the :ref:`data
8+
transform <data-coords>` of an image allows to manipulate the image's shape and
9+
orientation. This is an example of the concept of :ref:`transform chaining
10+
<transformation-pipeline>`.
11+
12+
The image of the output should have its boundary match the dashed yellow
13+
rectangle.
1614
"""
1715

1816
import numpy as np

examples/images_contours_and_fields/demo_bboximage.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
BboxImage Demo
44
==============
55
6-
A :class:`~matplotlib.image.BboxImage` can be used to position
7-
an image according to a bounding box. This demo shows how to
8-
show an image inside a `.text.Text`'s bounding box as well as
9-
how to manually create a bounding box for the image.
6+
A `~matplotlib.image.BboxImage` can be used to position an image according to
7+
a bounding box. This demo shows how to show an image inside a `.text.Text`'s
8+
bounding box as well as how to manually create a bounding box for the image.
109
"""
1110
import matplotlib.pyplot as plt
1211
import numpy as np

examples/images_contours_and_fields/image_annotated_heatmap.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@
3232
# tick labels (:meth:`set_xticklabels<matplotlib.axes.Axes.set_xticklabels>`),
3333
# otherwise they would become out of sync. The locations are just
3434
# the ascending integer numbers, while the ticklabels are the labels to show.
35-
# Finally we can label the data itself by creating a
36-
# :class:`~matplotlib.text.Text` within each cell showing the value of
37-
# that cell.
35+
# Finally we can label the data itself by creating a `~matplotlib.text.Text`
36+
# within each cell showing the value of that cell.
3837

3938

4039
import numpy as np
@@ -263,7 +262,7 @@ def annotate_heatmap(im, data=None, valfmt="{x:.2f}",
263262
textcolors=("red", "white"))
264263

265264
# Sometimes even the data itself is categorical. Here we use a
266-
# :class:`matplotlib.colors.BoundaryNorm` to get the data into classes
265+
# `matplotlib.colors.BoundaryNorm` to get the data into classes
267266
# and use this to colorize the plot, but also to obtain the class
268267
# labels from an array of classes.
269268

@@ -286,7 +285,7 @@ def annotate_heatmap(im, data=None, valfmt="{x:.2f}",
286285
# We can nicely plot a correlation matrix. Since this is bound by -1 and 1,
287286
# we use those as vmin and vmax. We may also remove leading zeros and hide
288287
# the diagonal elements (which are all 1) by using a
289-
# :class:`matplotlib.ticker.FuncFormatter`.
288+
# `matplotlib.ticker.FuncFormatter`.
290289

291290
corr_matrix = np.corrcoef(np.random.rand(6, 5))
292291
im, _ = heatmap(corr_matrix, vegetables, vegetables, ax=ax4,

examples/lines_bars_and_markers/scatter_with_legend.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
# -------------------------
3838
#
3939
# Another option for creating a legend for a scatter is to use the
40-
# :class:`~matplotlib.collections.PathCollection`'s
40+
# `~matplotlib.collections.PathCollection`'s
4141
# :meth:`~.PathCollection.legend_elements` method.
4242
# It will automatically try to determine a useful number of legend entries
4343
# to be shown and return a tuple of handles and labels. Those can be passed

examples/misc/keyword_plotting.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
======================
55
66
There are some instances where you have data in a format that lets you
7-
access particular variables with strings. For example, with
8-
:class:`numpy.recarray` or :class:`pandas.DataFrame`.
7+
access particular variables with strings: for example, with
8+
`numpy.recarray` or `pandas.DataFrame`.
99
1010
Matplotlib allows you provide such an object with the ``data`` keyword
1111
argument. If provided, then you may generate plots with the strings

examples/pie_and_polar_charts/pie_and_donut_labels.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@
1919
# automatic percentage labeling by showing absolute values; we calculate
2020
# the latter back from relative data and the known sum of all values.
2121
#
22-
# We then create the pie and store the returned objects for later.
23-
# The first returned element of the returned tuple is a list of the wedges.
24-
# Those are
25-
# :class:`matplotlib.patches.Wedge <matplotlib.patches.Wedge>` patches, which
26-
# can directly be used as the handles for a legend. We can use the
27-
# legend's ``bbox_to_anchor`` argument to position the legend outside of
28-
# the pie. Here we use the axes coordinates ``(1, 0, 0.5, 1)`` together
29-
# with the location ``"center left"``; i.e.
30-
# the left central point of the legend will be at the left central point of the
31-
# bounding box, spanning from ``(1, 0)`` to ``(1.5, 1)`` in axes coordinates.
22+
# We then create the pie and store the returned objects for later. The first
23+
# returned element of the returned tuple is a list of the wedges. Those are
24+
# `matplotlib.patches.Wedge` patches, which can directly be used as the handles
25+
# for a legend. We can use the legend's ``bbox_to_anchor`` argument to position
26+
# the legend outside of the pie. Here we use the axes coordinates ``(1, 0, 0.5,
27+
# 1)`` together with the location ``"center left"``; i.e. the left central
28+
# point of the legend will be at the left central point of the bounding box,
29+
# spanning from ``(1, 0)`` to ``(1.5, 1)`` in axes coordinates.
3230

3331
import numpy as np
3432
import matplotlib.pyplot as plt

examples/recipes/placing_text_boxes.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
Placing text boxes
33
==================
44
5-
When decorating axes with text boxes, two useful tricks are to place
6-
the text in axes coordinates (see :doc:`/tutorials/advanced/transforms_tutorial`), so the
7-
text doesn't move around with changes in x or y limits. You can also
8-
use the ``bbox`` property of text to surround the text with a
9-
:class:`~matplotlib.patches.Patch` instance -- the ``bbox`` keyword
10-
argument takes a dictionary with keys that are Patch properties.
5+
When decorating axes with text boxes, two useful tricks are to place the text
6+
in axes coordinates (see :doc:`/tutorials/advanced/transforms_tutorial`),
7+
so the text doesn't move around with changes in x or y limits. You
8+
can also use the ``bbox`` property of text to surround the text with a
9+
`~matplotlib.patches.Patch` instance -- the ``bbox`` keyword argument takes a
10+
dictionary with keys that are Patch properties.
1111
"""
1212

1313
import numpy as np

examples/shapes_and_collections/line_collection.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
66
Plotting lines with Matplotlib.
77
8-
:class:`~matplotlib.collections.LineCollection` allows one to plot multiple
8+
`~matplotlib.collections.LineCollection` allows one to plot multiple
99
lines on a figure. Below we show off some of its properties.
1010
"""
11+
1112
import matplotlib.pyplot as plt
1213
from matplotlib.collections import LineCollection
1314
from matplotlib import colors as mcolors
@@ -34,12 +35,12 @@
3435
ax.set_xlim(x.min(), x.max())
3536
ax.set_ylim(ys.min(), ys.max())
3637

37-
# colors is sequence of rgba tuples
38-
# linestyle is a string or dash tuple. Legal string values are
39-
# solid|dashed|dashdot|dotted. The dash tuple is (offset, onoffseq)
40-
# where onoffseq is an even length tuple of on and off ink in points.
41-
# If linestyle is omitted, 'solid' is used
42-
# See :class:`matplotlib.collections.LineCollection` for more information
38+
# *colors* is sequence of rgba tuples.
39+
# *linestyle* is a string or dash tuple. Legal string values are
40+
# solid|dashed|dashdot|dotted. The dash tuple is (offset, onoffseq) where
41+
# onoffseq is an even length tuple of on and off ink in points. If linestyle
42+
# is omitted, 'solid' is used.
43+
# See `matplotlib.collections.LineCollection` for more information.
4344
colors = [mcolors.to_rgba(c)
4445
for c in plt.rcParams['axes.prop_cycle'].by_key()['color']]
4546

@@ -69,7 +70,7 @@
6970
# solid|dashed|dashdot|dotted. The dash tuple is (offset, onoffseq)
7071
# where onoffseq is an even length tuple of on and off ink in points.
7172
# If linestyle is omitted, 'solid' is used
72-
# See :class:`matplotlib.collections.LineCollection` for more information
73+
# See `matplotlib.collections.LineCollection` for more information
7374

7475
# Make a sequence of (x, y) pairs.
7576
line_segments = LineCollection([np.column_stack([x, y]) for y in ys],

examples/shapes_and_collections/patch_collection.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
Circles, Wedges and Polygons
44
============================
55
6-
This example demonstrates how to use
7-
:class:`patch collections <.collections.PatchCollection>`.
6+
This example demonstrates how to use `.collections.PatchCollection`.
87
"""
98

109
import numpy as np

examples/text_labels_and_annotations/date.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
formatters. See :doc:`/gallery/ticks_and_spines/major_minor_demo` for more
88
information on controlling major and minor ticks.
99
10-
All matplotlib date plotting is done by converting date instances into days
11-
since 0001-01-01 00:00:00 UTC plus one day (for historical reasons). The
12-
conversion, tick locating and formatting is done behind the scenes so this
13-
is most transparent to you. The dates module provides several converter
14-
functions `matplotlib.dates.date2num` and `matplotlib.dates.num2date`.
15-
These can convert between `datetime.datetime` objects and
16-
:class:`numpy.datetime64` objects.
10+
All Matplotlib date plotting is done by converting date instances into
11+
days since 0001-01-01 00:00:00 UTC plus one day (for historical reasons).
12+
The conversion, tick locating and formatting is done behind the scenes
13+
so this is most transparent to you. The :mod:`matplotlib.dates` module
14+
provides the converter functions `.date2num` and `.num2date`, which convert
15+
`datetime.datetime` and `numpy.datetime64` objects to and from Matplotlib's
16+
internal representation.
1717
"""
1818

1919
import numpy as np

examples/ticks_and_spines/multiple_yaxis_with_spines.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""
1+
r"""
22
==========================
33
Multiple Yaxis With Spines
44
==========================
@@ -8,7 +8,7 @@
88
and offset its position using `~.spines.Spine.set_position`.
99
1010
Note that this approach uses `matplotlib.axes.Axes` and their
11-
:class:`Spines <matplotlib.spines.Spine>`. An alternative approach for parasite
11+
`~matplotlib.spines.Spine`\s. An alternative approach for parasite
1212
axes is shown in the :doc:`/gallery/axisartist/demo_parasite_axes` and
1313
:doc:`/gallery/axisartist/demo_parasite_axes2` examples.
1414
"""

examples/widgets/lasso_selector_demo_sgskip.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,13 @@ class SelectFromCollection:
3030
3131
Parameters
3232
----------
33-
ax : :class:`~matplotlib.axes.Axes`
33+
ax : `~matplotlib.axes.Axes`
3434
Axes to interact with.
35-
36-
collection : :class:`matplotlib.collections.Collection` subclass
35+
collection : `matplotlib.collections.Collection` subclass
3736
Collection you want to select from.
38-
3937
alpha_other : 0 <= float <= 1
4038
To highlight a selection, this tool sets all selected points to an
41-
alpha value of 1 and non-selected points to `alpha_other`.
39+
alpha value of 1 and non-selected points to *alpha_other*.
4240
"""
4341

4442
def __init__(self, ax, collection, alpha_other=0.3):

examples/widgets/polygon_selector_demo.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
=====================
55
66
Shows how one can select indices of a polygon interactively.
7-
87
"""
8+
99
import numpy as np
1010

1111
from matplotlib.widgets import PolygonSelector
1212
from matplotlib.path import Path
1313

1414

1515
class SelectFromCollection:
16-
"""Select indices from a matplotlib collection using `PolygonSelector`.
16+
"""
17+
Select indices from a matplotlib collection using `PolygonSelector`.
1718
1819
Selected indices are saved in the `ind` attribute. This tool fades out the
1920
points that are not part of the selection (i.e., reduces their alpha
@@ -25,15 +26,13 @@ class SelectFromCollection:
2526
2627
Parameters
2728
----------
28-
ax : :class:`~matplotlib.axes.Axes`
29+
ax : `~matplotlib.axes.Axes`
2930
Axes to interact with.
30-
31-
collection : :class:`matplotlib.collections.Collection` subclass
31+
collection : `matplotlib.collections.Collection` subclass
3232
Collection you want to select from.
33-
3433
alpha_other : 0 <= float <= 1
3534
To highlight a selection, this tool sets all selected points to an
36-
alpha value of 1 and non-selected points to `alpha_other`.
35+
alpha value of 1 and non-selected points to *alpha_other*.
3736
"""
3837

3938
def __init__(self, ax, collection, alpha_other=0.3):

0 commit comments

Comments
 (0)