From 5d367deb88915902872b60b6035fbf1570fa48ec Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Thu, 11 Aug 2022 13:02:37 +0200 Subject: [PATCH 1/8] Update example to use tick_params where possible --- examples/ticks/centered_ticklabels.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/ticks/centered_ticklabels.py b/examples/ticks/centered_ticklabels.py index 61431e3ab21c..34ab9e8b9083 100644 --- a/examples/ticks/centered_ticklabels.py +++ b/examples/ticks/centered_ticklabels.py @@ -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 @@ -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 @@ -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): + label.set_horizontalalignment('center') imid = len(r) // 2 ax.set_xlabel(str(r.date[imid].item().year)) plt.show() From 374023d29907b087df9ee9f81d504e72f176914c Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Thu, 11 Aug 2022 13:10:44 +0200 Subject: [PATCH 2/8] Illustrate offset in linestyle example --- examples/lines_bars_and_markers/linestyles.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/lines_bars_and_markers/linestyles.py b/examples/lines_bars_and_markers/linestyles.py index 88a363898da8..3e30f49acce1 100644 --- a/examples/lines_bars_and_markers/linestyles.py +++ b/examples/lines_bars_and_markers/linestyles.py @@ -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` @@ -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))), From 94633be92104d8ee26ebf69c1f1a5c817bdf738f Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Thu, 11 Aug 2022 13:22:19 +0200 Subject: [PATCH 3/8] Update Python version in the doc examples --- doc/users/installing/index.rst | 4 ++-- tutorials/introductory/customizing.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/users/installing/index.rst b/doc/users/installing/index.rst index 9641575d5046..1b6fdf65055f 100644 --- a/doc/users/installing/index.rst +++ b/doc/users/installing/index.rst @@ -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 :: diff --git a/tutorials/introductory/customizing.py b/tutorials/introductory/customizing.py index 9e74016c823e..ea6b501e99ea 100644 --- a/tutorials/introductory/customizing.py +++ b/tutorials/introductory/customizing.py @@ -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. From f4ca036f87c96b08271c61c7d095ea3041b64ea5 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Thu, 11 Aug 2022 13:39:27 +0200 Subject: [PATCH 4/8] Document that font.family can take a single or multiple entries and correct url --- lib/matplotlib/mpl-data/matplotlibrc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/mpl-data/matplotlibrc b/lib/matplotlib/mpl-data/matplotlibrc index c0c7e42f6c8f..c9e819b80d17 100644 --- a/lib/matplotlib/mpl-data/matplotlibrc +++ b/lib/matplotlib/mpl-data/matplotlibrc @@ -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 @@ -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), From 2698de3c992d13100d0f3ed58cd5d62945d54b23 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Thu, 11 Aug 2022 14:15:56 +0200 Subject: [PATCH 5/8] Clarify get_masked_triangles and minor grammar fix --- lib/matplotlib/tri/triangulation.py | 4 ++-- lib/matplotlib/tri/tricontour.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tri/triangulation.py b/lib/matplotlib/tri/triangulation.py index 53a63520ca74..00d8da4f4d28 100644 --- a/lib/matplotlib/tri/triangulation.py +++ b/lib/matplotlib/tri/triangulation.py @@ -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)*. """ @@ -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] diff --git a/lib/matplotlib/tri/tricontour.py b/lib/matplotlib/tri/tricontour.py index 8e2f66f4f78c..df3b44d941ef 100644 --- a/lib/matplotlib/tri/tricontour.py +++ b/lib/matplotlib/tri/tricontour.py @@ -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. 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 From b60661b6deb8df3e68604f9203a1d764a1e6678a Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Thu, 11 Aug 2022 14:57:33 +0200 Subject: [PATCH 6/8] Add example links to artist methods --- doc/api/artist_api.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/api/artist_api.rst b/doc/api/artist_api.rst index b635ed3bd0ba..ca2207e15dca 100644 --- a/doc/api/artist_api.rst +++ b/doc/api/artist_api.rst @@ -27,6 +27,7 @@ Interactive ----------- .. autosummary:: + :template: autosummary.rst :toctree: _as_gen :nosignatures: @@ -48,6 +49,7 @@ Clipping -------- .. autosummary:: + :template: autosummary.rst :toctree: _as_gen :nosignatures: @@ -62,6 +64,7 @@ Bulk Properties --------------- .. autosummary:: + :template: autosummary.rst :toctree: _as_gen :nosignatures: @@ -74,6 +77,7 @@ Drawing ------- .. autosummary:: + :template: autosummary.rst :toctree: _as_gen :nosignatures: @@ -107,6 +111,7 @@ Figure and Axes --------------- .. autosummary:: + :template: autosummary.rst :toctree: _as_gen :nosignatures: @@ -121,6 +126,7 @@ Children -------- .. autosummary:: + :template: autosummary.rst :toctree: _as_gen :nosignatures: @@ -131,6 +137,7 @@ Transform --------- .. autosummary:: + :template: autosummary.rst :toctree: _as_gen :nosignatures: @@ -142,6 +149,7 @@ Units ----- .. autosummary:: + :template: autosummary.rst :toctree: _as_gen :nosignatures: @@ -153,6 +161,7 @@ Metadata -------- .. autosummary:: + :template: autosummary.rst :toctree: _as_gen :nosignatures: @@ -167,6 +176,7 @@ Miscellaneous ------------- .. autosummary:: + :template: autosummary.rst :toctree: _as_gen :nosignatures: @@ -179,6 +189,7 @@ Functions ========= .. autosummary:: + :template: autosummary.rst :toctree: _as_gen :nosignatures: From 1cd2998c00f27c6f88ef9a44478fca0915d94bc4 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Thu, 11 Aug 2022 16:16:07 +0200 Subject: [PATCH 7/8] Remove non-existing legend Axes attribute from artist tutorial --- tutorials/intermediate/artists.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tutorials/intermediate/artists.py b/tutorials/intermediate/artists.py index 16c4566071f2..f76c62d8462c 100644 --- a/tutorials/intermediate/artists.py +++ b/tutorials/intermediate/artists.py @@ -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 @@ -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 @@ -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 From 137ebfa2df09b91e833ee2739582f17d324ec32b Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Thu, 11 Aug 2022 16:36:17 +0200 Subject: [PATCH 8/8] Update URLs --- lib/matplotlib/mpl-data/matplotlibrc | 7 ++++--- setup.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/mpl-data/matplotlibrc b/lib/matplotlib/mpl-data/matplotlibrc index c9e819b80d17..e65e3c209030 100644 --- a/lib/matplotlib/mpl-data/matplotlibrc +++ b/lib/matplotlib/mpl-data/matplotlibrc @@ -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 diff --git a/setup.py b/setup.py index 53131df5bb6b..b7f9b98c12e8 100644 --- a/setup.py +++ b/setup.py @@ -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',