Skip to content

Fix issues in examples, docs, and tutorials #23605

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 8 commits into from
Aug 14, 2022
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
11 changes: 11 additions & 0 deletions doc/api/artist_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Interactive
-----------

.. autosummary::
:template: autosummary.rst
:toctree: _as_gen
:nosignatures:

Expand All @@ -48,6 +49,7 @@ Clipping
--------

.. autosummary::
:template: autosummary.rst
:toctree: _as_gen
:nosignatures:

Expand All @@ -62,6 +64,7 @@ Bulk Properties
---------------

.. autosummary::
:template: autosummary.rst
:toctree: _as_gen
:nosignatures:

Expand All @@ -74,6 +77,7 @@ Drawing
-------

.. autosummary::
:template: autosummary.rst
:toctree: _as_gen
:nosignatures:

Expand Down Expand Up @@ -107,6 +111,7 @@ Figure and Axes
---------------

.. autosummary::
:template: autosummary.rst
:toctree: _as_gen
:nosignatures:

Expand All @@ -121,6 +126,7 @@ Children
--------

.. autosummary::
:template: autosummary.rst
:toctree: _as_gen
:nosignatures:

Expand All @@ -131,6 +137,7 @@ Transform
---------

.. autosummary::
:template: autosummary.rst
:toctree: _as_gen
:nosignatures:

Expand All @@ -142,6 +149,7 @@ Units
-----

.. autosummary::
:template: autosummary.rst
:toctree: _as_gen
:nosignatures:

Expand All @@ -153,6 +161,7 @@ Metadata
--------

.. autosummary::
:template: autosummary.rst
:toctree: _as_gen
:nosignatures:

Expand All @@ -167,6 +176,7 @@ Miscellaneous
-------------

.. autosummary::
:template: autosummary.rst
:toctree: _as_gen
:nosignatures:

Expand All @@ -179,6 +189,7 @@ Functions
=========

.. autosummary::
:template: autosummary.rst
:toctree: _as_gen
:nosignatures:

Expand Down
4 changes: 2 additions & 2 deletions doc/users/installing/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ at the Terminal.app command line::

You should see something like ::

3.0.0 /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/__init__.py
3.6.0 /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/matplotlib/__init__.py

where ``3.0.0`` is the Matplotlib version you just installed, and the path
where ``3.6.0`` is the Matplotlib version you just installed, and the path
following depends on whether you are using Python.org Python, Homebrew or
Macports. If you see another version, or you get an error like ::

Expand Down
7 changes: 4 additions & 3 deletions examples/lines_bars_and_markers/linestyles.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
Simple linestyles can be defined using the strings "solid", "dotted", "dashed"
or "dashdot". More refined control can be achieved by providing a dash tuple
``(offset, (on_off_seq))``. For example, ``(0, (3, 10, 1, 15))`` means
(3pt line, 10pt space, 1pt line, 15pt space) with no offset. See also
`.Line2D.set_linestyle`.
(3pt line, 10pt space, 1pt line, 15pt space) with no offset, while
``(5, (10, 3))``, means (10pt line, 3pt space), but skip the first 5pt line.
See also `.Line2D.set_linestyle`.

*Note*: The dash style can also be configured via `.Line2D.set_dashes`
as shown in :doc:`/gallery/lines_bars_and_markers/line_demo_dash_control`
Expand All @@ -27,7 +28,7 @@
('loosely dotted', (0, (1, 10))),
('dotted', (0, (1, 1))),
('densely dotted', (0, (1, 1))),

('long dash with offset', (5, (10, 3))),
('loosely dashed', (0, (5, 10))),
('dashed', (0, (5, 5))),
('densely dashed', (0, (5, 1))),
Expand Down
13 changes: 7 additions & 6 deletions examples/ticks/centered_ticklabels.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'center', 'left', or 'right' can be controlled using the horizontal alignment
property::

for label in ax.xaxis.get_xticklabels():
for label in ax.get_xticklabels():
label.set_horizontalalignment('right')

However there is no direct way to center the labels between ticks. To fake
Expand All @@ -23,7 +23,7 @@
import matplotlib.ticker as ticker
import matplotlib.pyplot as plt

# load some financial data; Google's stock price
# Load some financial data; Google's stock price
r = (cbook.get_sample_data('goog.npz', np_load=True)['price_data']
.view(np.recarray))
r = r[-250:] # get the last 250 days
Expand All @@ -38,11 +38,12 @@
ax.xaxis.set_major_formatter(ticker.NullFormatter())
ax.xaxis.set_minor_formatter(dates.DateFormatter('%b'))

for tick in ax.xaxis.get_minor_ticks():
tick.tick1line.set_markersize(0)
tick.tick2line.set_markersize(0)
tick.label1.set_horizontalalignment('center')
# Remove the tick lines
ax.tick_params(axis='x', which='minor', tick1On=False, tick2On=False)

# Align the minor tick label
for label in ax.get_xticklabels(minor=True):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is maybe not the best thing to loop over. But this is the method mentioned at the top, so from that perspective it makes more sense.

label.set_horizontalalignment('center')
imid = len(r) // 2
ax.set_xlabel(str(r.date[imid].item().year))
plt.show()
15 changes: 8 additions & 7 deletions lib/matplotlib/mpl-data/matplotlibrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
## $HOME/.matplotlib/matplotlibrc
## and edit that copy.
##
## See https://matplotlib.org/users/customizing.html#the-matplotlibrc-file
## See https://matplotlib.org/stable/tutorials/introductory/customizing.html#customizing-with-matplotlibrc-files
## for more details on the paths which are checked for the configuration file.
##
## Blank lines, or lines starting with a comment symbol, are ignored, as are
Expand Down Expand Up @@ -218,9 +218,9 @@
## on font properties. The 6 font properties used for font matching are
## given below with their default values.
##
## The font.family property can take either a concrete font name (not supported
## when rendering text with usetex), or one of the following five generic
## values:
## The font.family property can take either a single or multiple entries of any
## combination of concrete font names (not supported when rendering text with
## usetex) or the following five generic values:
## - 'serif' (e.g., Times),
## - 'sans-serif' (e.g., Helvetica),
## - 'cursive' (e.g., Zapf-Chancery),
Expand Down Expand Up @@ -738,9 +738,10 @@
## * INTERACTIVE KEYMAPS *
## ***************************************************************************
## Event keys to interact with figures/plots via keyboard.
## See https://matplotlib.org/users/navigation_toolbar.html for more details on
## interactive navigation. Customize these settings according to your needs.
## Leave the field(s) empty if you don't need a key-map. (i.e., fullscreen : '')
## See https://matplotlib.org/stable/users/explain/interactive.html for more
## details on interactive navigation. Customize these settings according to
## your needs. Leave the field(s) empty if you don't need a key-map. (i.e.,
## fullscreen : '')
#keymap.fullscreen: f, ctrl+f # toggling
#keymap.home: h, r, home # home or reset mnemonic
#keymap.back: left, c, backspace, MouseButton.BACK # forward / backward keys
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/tri/triangulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def edges(self):
Return integer array of shape (nedges, 2) containing all edges of
non-masked triangles.

Each row defines an edge by it's start point index and end point
Each row defines an edge by its start point index and end point
index. Each edge appears only once, i.e. for an edge between points
*i* and *j*, there will only be either *(i, j)* or *(j, i)*.
"""
Expand All @@ -126,7 +126,7 @@ def get_cpp_triangulation(self):

def get_masked_triangles(self):
"""
Return an array of triangles that are not masked.
Return an array of triangles taking the mask into account.
"""
if self.mask is not None:
return self.triangles[~self.mask]
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tri/tricontour.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def _contour_args(self, args, kwargs):
The colors of the levels, i.e., the contour %%(type)s.

The sequence is cycled for the levels in ascending order. If the sequence
is shorter than the number of levels, it's repeated.
is shorter than the number of levels, it is repeated.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really required. More a consequence of the other instance being incorrect.


As a shortcut, single color strings may be used in place of one-element
lists, i.e. ``'red'`` instead of ``['red']`` to color all levels with the
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def make_release_tree(self, base_dir, files):
author="John D. Hunter, Michael Droettboom",
author_email="matplotlib-users@python.org",
url="https://matplotlib.org",
download_url="https://matplotlib.org/users/installing.html",
download_url="https://matplotlib.org/stable/users/installing/index.html",
project_urls={
'Documentation': 'https://matplotlib.org',
'Source Code': 'https://github.com/matplotlib/matplotlib',
Expand Down
24 changes: 12 additions & 12 deletions tutorials/intermediate/artists.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ class in the Matplotlib API, and the one you will be working with most
# images A list of `.FigureImage` patches -
# useful for raw pixel display
# legends A list of Figure `.Legend` instances
# (different from ``Axes.legends``)
# (different from ``Axes.get_legend()``)
# lines A list of Figure `.Line2D` instances
# (rarely used, see ``Axes.lines``)
# patches A list of Figure `.Patch`\s
Expand Down Expand Up @@ -543,7 +543,7 @@ class in the Matplotlib API, and the one you will be working with most
# `~.axes.Axes.fill` - shared area `.Polygon` ax.patches
# `~.axes.Axes.hist` - histograms `.Rectangle` ax.patches
# `~.axes.Axes.imshow` - image data `.AxesImage` ax.images
# `~.axes.Axes.legend` - Axes legends `.Legend` ax.legends
# `~.axes.Axes.legend` - Axes legend `.Legend` ax.get_legend()
# `~.axes.Axes.plot` - xy plots `.Line2D` ax.lines
# `~.axes.Axes.scatter` - scatter charts `.PolyCollection` ax.collections
# `~.axes.Axes.text` - text `.Text` ax.texts
Expand All @@ -563,26 +563,26 @@ class in the Matplotlib API, and the one you will be working with most
# the font color of the ``XAxis`` ticklabels using the ``Axes`` helper
# method::
#
# for label in ax.get_xticklabels():
# label.set_color('orange')
# ax.tick_params(axis='x', labelcolor='orange')
#
# Below is a summary of the Artists that the Axes contains
# Below is a summary of the Artists that the `~.axes.Axes` contains
#
# ============== =========================================
# Axes attribute Description
# ============== =========================================
# artists A list of `.Artist` instances
# artists An `.ArtistList` of `.Artist` instances
# patch `.Rectangle` instance for Axes background
# collections A list of `.Collection` instances
# images A list of `.AxesImage`
# legends A list of `.Legend` instances
# lines A list of `.Line2D` instances
# patches A list of `.Patch` instances
# texts A list of `.Text` instances
# collections An `.ArtistList` of `.Collection` instances
# images An `.ArtistList` of `.AxesImage`
# lines An `.ArtistList` of `.Line2D` instances
# patches An `.ArtistList` of `.Patch` instances
# texts An `.ArtistList` of `.Text` instances
# xaxis A `matplotlib.axis.XAxis` instance
# yaxis A `matplotlib.axis.YAxis` instance
# ============== =========================================
#
# The legend can be accessed by `~.axes.Axes.get_legend`,
#
# .. _axis-container:
#
# Axis containers
Expand Down
4 changes: 2 additions & 2 deletions tutorials/introductory/customizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ def plotting_function():
#
# 4. :file:`{INSTALL}/matplotlib/mpl-data/matplotlibrc`, where
# :file:`{INSTALL}` is something like
# :file:`/usr/lib/python3.7/site-packages` on Linux, and maybe
# :file:`C:\\Python37\\Lib\\site-packages` on Windows. Every time you
# :file:`/usr/lib/python3.9/site-packages` on Linux, and maybe
# :file:`C:\\Python39\\Lib\\site-packages` on Windows. Every time you
# install matplotlib, this file will be overwritten, so if you want
# your customizations to be saved, please move this file to your
# user-specific matplotlib directory.
Expand Down