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

Skip to content

Commit eb85c81

Browse files
committed
Merge branch 'nested_ax_zoom' of https://github.com/raphaelquast/matplotlib into nested_ax_zoom
2 parents 935d1b6 + 9de88c8 commit eb85c81

File tree

80 files changed

+1347
-613
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1347
-613
lines changed

.github/workflows/cibuildwheel.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,31 +136,31 @@ jobs:
136136
path: dist/
137137

138138
- name: Build wheels for CPython 3.11
139-
uses: pypa/cibuildwheel@66b46d086804a9e9782354100d96a3a445431bca # v2.14.0
139+
uses: pypa/cibuildwheel@f21bb8376a051ffb6cb5604b28ccaef7b90e8ab7 # v2.14.1
140140
with:
141141
package-dir: dist/${{ needs.build_sdist.outputs.SDIST_NAME }}
142142
env:
143143
CIBW_BUILD: "cp311-*"
144144
CIBW_ARCHS: ${{ matrix.cibw_archs }}
145145

146146
- name: Build wheels for CPython 3.10
147-
uses: pypa/cibuildwheel@66b46d086804a9e9782354100d96a3a445431bca # v2.14.0
147+
uses: pypa/cibuildwheel@f21bb8376a051ffb6cb5604b28ccaef7b90e8ab7 # v2.14.1
148148
with:
149149
package-dir: dist/${{ needs.build_sdist.outputs.SDIST_NAME }}
150150
env:
151151
CIBW_BUILD: "cp310-*"
152152
CIBW_ARCHS: ${{ matrix.cibw_archs }}
153153

154154
- name: Build wheels for CPython 3.9
155-
uses: pypa/cibuildwheel@66b46d086804a9e9782354100d96a3a445431bca # v2.14.0
155+
uses: pypa/cibuildwheel@f21bb8376a051ffb6cb5604b28ccaef7b90e8ab7 # v2.14.1
156156
with:
157157
package-dir: dist/${{ needs.build_sdist.outputs.SDIST_NAME }}
158158
env:
159159
CIBW_BUILD: "cp39-*"
160160
CIBW_ARCHS: ${{ matrix.cibw_archs }}
161161

162162
- name: Build wheels for PyPy
163-
uses: pypa/cibuildwheel@66b46d086804a9e9782354100d96a3a445431bca # v2.14.0
163+
uses: pypa/cibuildwheel@f21bb8376a051ffb6cb5604b28ccaef7b90e8ab7 # v2.14.1
164164
with:
165165
package-dir: dist/${{ needs.build_sdist.outputs.SDIST_NAME }}
166166
env:

LICENSE/LICENSE_COLORBREWER

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,13 @@
1-
Apache-Style Software License for ColorBrewer Color Schemes
1+
Apache-Style Software License for ColorBrewer software and ColorBrewer Color Schemes
22

3-
Version 1.1
3+
Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The Pennsylvania State University.
44

5-
Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The Pennsylvania
6-
State University. All rights reserved. Redistribution and use in source
7-
and binary forms, with or without modification, are permitted provided
8-
that the following conditions are met:
5+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
97

10-
1. Redistributions as source code must retain the above copyright notice,
11-
this list of conditions and the following disclaimer.
8+
http://www.apache.org/licenses/LICENSE-2.0
129

13-
2. The end-user documentation included with the redistribution, if any,
14-
must include the following acknowledgment: "This product includes color
15-
specifications and designs developed by Cynthia Brewer
16-
(http://colorbrewer.org/)." Alternately, this acknowledgment may appear in
17-
the software itself, if and wherever such third-party acknowledgments
18-
normally appear.
19-
20-
3. The name "ColorBrewer" must not be used to endorse or promote products
21-
derived from this software without prior written permission. For written
22-
permission, please contact Cynthia Brewer at [email protected].
23-
24-
4. Products derived from this software may not be called "ColorBrewer",
25-
nor may "ColorBrewer" appear in their name, without prior written
26-
permission of Cynthia Brewer.
27-
28-
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES,
29-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
30-
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
31-
CYNTHIA BREWER, MARK HARROWER, OR THE PENNSYLVANIA STATE UNIVERSITY BE
32-
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33-
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34-
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35-
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36-
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37-
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38-
POSSIBILITY OF SUCH DAMAGE.
10+
Unless required by applicable law or agreed to in writing, software distributed
11+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
13+
specific language governing permissions and limitations under the License.

doc/_static/mpl.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,29 @@
99
margin: 0;
1010
}
1111

12+
/* Make announcement an error colour for unreleased documentation, and sticky. */
13+
#unreleased-message.bd-header-announcement {
14+
border-bottom: solid var(--pst-color-danger-highlight);
15+
color: var(--pst-color-danger-text);
16+
font-weight: var(--pst-admonition-font-weight-heading);
17+
position: sticky;
18+
top: 0;
19+
z-index: 1050;
20+
}
21+
22+
#unreleased-message.bd-header-announcement:after {
23+
background-color: var(--pst-color-danger);
24+
opacity: 1;
25+
}
26+
27+
#unreleased-message.bd-header-announcement a {
28+
color: var(--pst-color-danger-text);
29+
}
30+
31+
#unreleased-message.bd-header-announcement + .bd-navbar {
32+
top: 3rem; /* Minimum height of announcement header. */
33+
}
34+
1235
/* multi column TOC */
1336
.contents ul {
1437
list-style-type: none;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{%- if theme_announcement == "unreleased" -%}
2+
{% set header_classes = ["bd-header-announcement", "container-fluid"] %}
3+
<div class="{{ header_classes | join(' ') }}" id="unreleased-message">
4+
<div class="bd-header-announcement__content">
5+
You are reading documentation for the unreleased version of Matplotlib.
6+
<a href="https://matplotlib.org/search.html?q={{ title | striptags | urlencode }}&amp;check_keywords=yes&amp;area=default">
7+
Try searching for the released version of this page instead?
8+
</a>
9+
</div>
10+
</div>
11+
{%- else -%}
12+
{%- extends "!sections/announcement.html" -%}
13+
{%- endif %}

doc/api/font_manager_api.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
:undoc-members:
88
:show-inheritance:
99

10-
.. data:: fontManager
10+
.. data:: fontManager
1111

12-
The global instance of `FontManager`.
12+
The global instance of `FontManager`.
1313

1414
.. autoclass:: FontEntry
1515
:no-undoc-members:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
``TexManager.texcache``
2+
~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
... is considered private and deprecated. The location of the cache directory is
5+
clarified in the doc-string.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``inset_location.InsetPosition`` is deprecated
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
Use `~.Axes.inset_axes` instead.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
``axisartist.axes_grid`` and ``axisartist.axes_rgb``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
These modules, which provide wrappers combining the functionality of
4+
`.axes_grid1` and `.axisartist`, are deprecated; directly use e.g.
5+
``AxesGrid(..., axes_class=axislines.Axes)`` instead.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Support for Qt<5.12 has been dropped
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... as there are no wheels or conda packages that support both Qt 5.11 (or
4+
older) and Python 3.9 (or newer).

doc/conf.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,11 @@ def js_tag_with_cache_busting(js):
462462
},
463463
"navbar_end": ["theme-switcher", "version-switcher", "mpl_icon_links"],
464464
"secondary_sidebar_items": "page-toc.html",
465-
"footer_start": ["copyright", "sphinx-version", "doc_version"],
465+
"footer_start": ["copyright", "sphinx-version", "doc_version"],
466+
# We override the announcement template from pydata-sphinx-theme, where
467+
# this special value indicates the use of the unreleased banner. If we need
468+
# an actual announcement, then just place the text here as usual.
469+
"announcement": "unreleased" if not is_release_build else "",
466470
}
467471
include_analytics = is_release_build
468472
if include_analytics:
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Clipping for contour plots
2+
--------------------------
3+
4+
`~.Axes.contour` and `~.Axes.contourf` now accept the *clip_path* parameter.
5+
6+
.. plot::
7+
:include-source: true
8+
9+
import numpy as np
10+
import matplotlib.pyplot as plt
11+
import matplotlib.patches as mpatches
12+
13+
x = y = np.arange(-3.0, 3.01, 0.025)
14+
X, Y = np.meshgrid(x, y)
15+
Z1 = np.exp(-X**2 - Y**2)
16+
Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
17+
Z = (Z1 - Z2) * 2
18+
19+
fig, ax = plt.subplots()
20+
patch = mpatches.RegularPolygon((0, 0), 5, radius=2,
21+
transform=ax.transData)
22+
ax.contourf(X, Y, Z, clip_path=patch)
23+
24+
plt.show()
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
macosx: New figures can be opened in either windows or tabs
2+
-----------------------------------------------------------
3+
4+
There is a new :rc:`macosx.window_mode`` rcParam to control how
5+
new figures are opened with the macosx backend. The default is
6+
**system** which uses the system settings, or one can specify either
7+
**tab** or **window** to explicitly choose the mode used to open new figures.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
``mathtext`` has more sizable delimiters
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The ``\lgroup`` and ``\rgroup`` sizable delimiters have been added.
5+
6+
The following delimiter names have been supported earlier, but can now be sized with
7+
``\left`` and ``\right``:
8+
9+
* ``\lbrace``, ``\rbrace``, ``\leftbrace``, and ``\rightbrace``
10+
* ``\lbrack`` and ``\rbrack``
11+
* ``\leftparen`` and ``\rightparen``
12+
13+
There are really no obvious advantages in using these.
14+
Instead, they are are added for completeness.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
``rcParams['legend.loc']`` now accepts float-tuple inputs
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The :rc:`legend.loc` rcParams now accepts float-tuple inputs, same as the *loc* keyword argument to `.Legend`.
5+
This allows users to set the location of the legend in a more flexible and consistent way.

galleries/examples/misc/demo_ribbon_box.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def main():
8686
background_gradient[:, :, :3] = [1, 1, 0]
8787
background_gradient[:, :, 3] = [[0.1, 0.3], [0.3, 0.5]] # alpha channel
8888
ax.imshow(background_gradient, interpolation="bicubic", zorder=0.1,
89-
extent=(0, 1, 0, 1), transform=ax.transAxes, aspect="auto")
89+
extent=(0, 1, 0, 1), transform=ax.transAxes)
9090

9191
plt.show()
9292

galleries/examples/scales/custom_scale.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""
2+
.. _custom_scale:
3+
24
============
35
Custom scale
46
============

galleries/examples/specialty_plots/mri_with_eeg.py

Lines changed: 22 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,30 @@
1111
import numpy as np
1212

1313
import matplotlib.cbook as cbook
14-
import matplotlib.cm as cm
15-
from matplotlib.collections import LineCollection
16-
from matplotlib.ticker import MultipleLocator
1714

18-
fig = plt.figure("MRI_with_EEG")
15+
fig, axd = plt.subplot_mosaic(
16+
[["image", "density"],
17+
["EEG", "EEG"]],
18+
layout="constrained",
19+
# "image" will contain a square image. We fine-tune the width so that
20+
# there is no excess horizontal or vertical margin around the image.
21+
width_ratios=[1.05, 2],
22+
)
1923

2024
# Load the MRI data (256x256 16-bit integers)
2125
with cbook.get_sample_data('s1045.ima.gz') as dfile:
2226
im = np.frombuffer(dfile.read(), np.uint16).reshape((256, 256))
2327

2428
# Plot the MRI image
25-
ax0 = fig.add_subplot(2, 2, 1)
26-
ax0.imshow(im, cmap=cm.gray)
27-
ax0.axis('off')
29+
axd["image"].imshow(im, cmap="gray")
30+
axd["image"].axis('off')
2831

2932
# Plot the histogram of MRI intensity
30-
ax1 = fig.add_subplot(2, 2, 2)
31-
im = np.ravel(im)
32-
im = im[np.nonzero(im)] # Ignore the background
33-
im = im / (2**16 - 1) # Normalize
34-
ax1.hist(im, bins=100)
35-
ax1.xaxis.set_major_locator(MultipleLocator(0.4))
36-
ax1.minorticks_on()
37-
ax1.set_yticks([])
38-
ax1.set_xlabel('Intensity (a.u.)')
39-
ax1.set_ylabel('MRI density')
33+
im = im[im.nonzero()] # Ignore the background
34+
axd["density"].hist(im, bins=np.arange(0, 2**16+1, 512))
35+
axd["density"].set(xlabel='Intensity (a.u.)', xlim=(0, 2**16),
36+
ylabel='MRI density', yticks=[])
37+
axd["density"].minorticks_on()
4038

4139
# Load the EEG data
4240
n_samples, n_rows = 800, 4
@@ -45,33 +43,13 @@
4543
t = 10 * np.arange(n_samples) / n_samples
4644

4745
# Plot the EEG
48-
ticklocs = []
49-
ax2 = fig.add_subplot(2, 1, 2)
50-
ax2.set_xlim(0, 10)
51-
ax2.set_xticks(np.arange(10))
52-
dmin = data.min()
53-
dmax = data.max()
54-
dr = (dmax - dmin) * 0.7 # Crowd them a bit.
55-
y0 = dmin
56-
y1 = (n_rows - 1) * dr + dmax
57-
ax2.set_ylim(y0, y1)
46+
axd["EEG"].set_xlabel('Time (s)')
47+
axd["EEG"].set_xlim(0, 10)
48+
dy = (data.min() - data.max()) * 0.7 # Crowd them a bit.
49+
axd["EEG"].set_ylim(-dy, n_rows * dy)
50+
axd["EEG"].set_yticks([0, dy, 2*dy, 3*dy], labels=['PG3', 'PG5', 'PG7', 'PG9'])
5851

59-
segs = []
60-
for i in range(n_rows):
61-
segs.append(np.column_stack((t, data[:, i])))
62-
ticklocs.append(i * dr)
52+
for i, data_col in enumerate(data.T):
53+
axd["EEG"].plot(t, data_col + i*dy, color="C0")
6354

64-
offsets = np.zeros((n_rows, 2), dtype=float)
65-
offsets[:, 1] = ticklocs
66-
67-
lines = LineCollection(segs, offsets=offsets, offset_transform=None)
68-
ax2.add_collection(lines)
69-
70-
# Set the yticks to use axes coordinates on the y-axis
71-
ax2.set_yticks(ticklocs, labels=['PG3', 'PG5', 'PG7', 'PG9'])
72-
73-
ax2.set_xlabel('Time (s)')
74-
75-
76-
plt.tight_layout()
7755
plt.show()

galleries/users_explain/artists/artist_intro.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ Introduction to Artists
55

66
Almost all objects you interact with on a Matplotlib plot are called "Artist"
77
(and are subclasses of the `.Artist` class). :doc:`Figure <../figure/index>`
8-
and :doc:`Axes <../axes/index>` are Artists, and generally contain :doc:`Axis
9-
<../axis/index>` Artists and Artists that contain data or annotation
10-
information.
8+
and :doc:`Axes <../axes/index>` are Artists, and generally contain
9+
`~.axis.Axis` Artists and Artists that contain data or annotation information.
1110

1211

1312
Creating Artists

galleries/users_explain/artists/index.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ Artists
44

55
Almost all objects you interact with on a Matplotlib plot are called "Artist"
66
(and are subclasses of the `.Artist` class). :doc:`Figure <../figure/index>`
7-
and :doc:`Axes <../axes/index>` are Artists, and generally contain :doc:`Axis
8-
<../axis/index>` Artists and Artists that contain data or annotation
9-
information.
7+
and :doc:`Axes <../axes/index>` are Artists, and generally contain
8+
`~.axis.Axis` Artists and Artists that contain data or annotation information.
109

1110
.. toctree::
1211
:maxdepth: 2

galleries/users_explain/axes/axes_intro.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Introduction to Axes (or Subplots)
55

66
Matplotlib `~.axes.Axes` are the gateway to creating your data visualizations.
77
Once an Axes is placed on a figure there are many methods that can be used to
8-
add data to the Axes. An Axes typically has a pair of :doc:`Axis <../axis/index>`
8+
add data to the Axes. An Axes typically has a pair of `~.axis.Axis`
99
Artists that define the data coordinate system, and include methods to add
1010
annotations like x- and y-labels, titles, and legends.
1111

@@ -130,7 +130,7 @@ Note that text can also be added to axes using `~.axes.Axes.text`, and `~.axes.A
130130
Axes limits, scales, and ticking
131131
--------------------------------
132132

133-
Each Axes has two (or more) `~.axis.Axis` objects, that can be accessed via :attr:`~matplotlib.axes.Axes.xaxis` and :attr:`~matplotlib.axes.Axes.yaxis` properties. These have substantial number of methods on them, and for highly customizable Axis-es it is useful to read more about that API (:doc:`../axis/index`). However, the Axes class offers a number of helpers for the most common of these methods. Indeed, the `~.axes.Axes.set_xlabel`, discussed above, is a helper for the `~.Axis.set_label_text`.
133+
Each Axes has two (or more) `~.axis.Axis` objects, that can be accessed via :attr:`~matplotlib.axes.Axes.xaxis` and :attr:`~matplotlib.axes.Axes.yaxis` properties. These have substantial number of methods on them, and for highly customizable Axis-es it is useful to read the API at `~.axis.Axis`. However, the Axes class offers a number of helpers for the most common of these methods. Indeed, the `~.axes.Axes.set_xlabel`, discussed above, is a helper for the `~.Axis.set_label_text`.
134134

135135
Other important methods set the extent on the axes (`~.axes.Axes.set_xlim`, `~.axes.Axes.set_ylim`), or more fundamentally the scale of the axes. So for instance, we can make an Axis have a logarithmic scale, and zoom in on a sub-portion of the data:
136136

@@ -158,7 +158,7 @@ Many aspects of Axes ticks and tick labeling can be adjusted using `~.axes.Axes.
158158
labelcolor='green')
159159

160160

161-
More fine-grained control on ticks, setting scales, and controlling the Axis can be highly customized beyond these Axes-level helpers. An introduction to these methods can be found in :ref:`users_axis`, or the API reference for `.axis.Axis`.
161+
More fine-grained control on ticks, setting scales, and controlling the Axis can be highly customized beyond these Axes-level helpers.
162162

163163
Axes layout
164164
-----------

0 commit comments

Comments
 (0)