8000 Fix some examples docstrings. · matplotlib/matplotlib@bda5d20 · GitHub
[go: up one dir, main page]

Skip to content

Commit bda5d20

Browse files
committed
Fix some examples docstrings.
Remove extraneous :class:. Additionally reword the docs for affine_image.py (all backends support affine transforms on images) and date.py (wrt. date2num and num2date).
1 parent 612aa5c commit bda5d20

File tree

13 files changed

+59
-68
lines changed

13 files changed

+59
-68
lines changed

examples/images_contours_and_fields/affine_image.py

Lines changed: 7 additions & 9 deletions
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

Lines changed: 3 additions & 4 deletions
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

Lines changed: 4 additions & 5 deletions
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
# Somet 9E81 imes 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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 8 additions & 10 deletions
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

Lines changed: 6 additions & 6 deletions
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

Lines changed: 9 additions & 8 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 7 additions & 7 deletions
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. 8330 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

0 commit comments

Comments
 (0)
0