Skip to content

Commit 4697637

Browse files
committed
Merge branch 'main' into text-overhaul
2 parents a403858 + 73d0317 commit 4697637

File tree

131 files changed

+1285
-733
lines changed

Some content is hidden

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

131 files changed

+1285
-733
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ skip_commits:
1717

1818
clone_depth: 50
1919

20-
image: Visual Studio 2019
20+
image: Visual Studio 2022
2121

2222
environment:
2323

.github/workflows/cibuildwheel.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,27 @@ jobs:
140140
name: cibw-sdist
141141
path: dist/
142142

143+
- name: Build wheels for CPython 3.14
144+
uses: pypa/cibuildwheel@5f22145df44122af0f5a201f93cf0207171beca7 # v3.0.0
145+
with:
146+
package-dir: dist/${{ needs.build_sdist.outputs.SDIST_NAME }}
147+
env:
148+
CIBW_BUILD: "cp314-* cp314t-*"
149+
CIBW_ENABLE: "cpython-freethreading cpython-prerelease"
150+
CIBW_ARCHS: ${{ matrix.cibw_archs }}
151+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
152+
CIBW_BEFORE_TEST: >-
153+
python -m pip install
154+
--index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
155+
--upgrade --pre --only-binary=:all: contourpy numpy pillow
156+
143157
- name: Build wheels for CPython 3.13
144158
uses: pypa/cibuildwheel@5f22145df44122af0f5a201f93cf0207171beca7 # v3.0.0
145159
with:
146160
package-dir: dist/${{ needs.build_sdist.outputs.SDIST_NAME }}
147161
env:
148162
CIBW_BUILD: "cp313-* cp313t-*"
149163
CIBW_ENABLE: cpython-freethreading
150-
# No free-threading wheels available for aarch64 on Pillow.
151-
CIBW_TEST_SKIP: "cp313t-manylinux_aarch64"
152164
CIBW_ARCHS: ${{ matrix.cibw_archs }}
153165

154166
- name: Build wheels for CPython 3.12
@@ -167,7 +179,6 @@ jobs:
167179
CIBW_BUILD: "cp311-*"
168180
CIBW_ARCHS: ${{ matrix.cibw_archs }}
169181

170-
171182
- name: Build wheels for PyPy
172183
uses: pypa/cibuildwheel@5f22145df44122af0f5a201f93cf0207171beca7 # v3.0.0
173184
with:
@@ -176,8 +187,6 @@ jobs:
176187
CIBW_BUILD: "pp311-*"
177188
CIBW_ARCHS: ${{ matrix.cibw_archs }}
178189
CIBW_ENABLE: pypy
179-
# No wheels available for Pillow with pp311 yet.
180-
CIBW_TEST_SKIP: "pp311*"
181190
if: matrix.cibw_archs != 'aarch64' && matrix.os != 'windows-latest'
182191

183192
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
persist-credentials: false
3333

3434
- name: Initialize CodeQL
35-
uses: github/codeql-action/init@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3.29.0
35+
uses: github/codeql-action/init@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
3636
with:
3737
languages: ${{ matrix.language }}
3838

@@ -43,4 +43,4 @@ jobs:
4343
pip install --user -v .
4444
4545
- name: Perform CodeQL Analysis
46-
uses: github/codeql-action/analyze@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3.29.0
46+
uses: github/codeql-action/analyze@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2

.github/workflows/tests.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,15 @@ jobs:
365365
run: |
366366
function remove_files() {
367367
local extension=$1
368-
find ./result_images -type f -name "*-expected*.$extension" | while read file; do
368+
find ./result_images -name "*-expected*.$extension" | while read file; do
369369
if [[ $file == *"-expected_pdf"* ]]; then
370370
base=${file%-expected_pdf.$extension}_pdf
371371
elif [[ $file == *"-expected_eps"* ]]; then
372372
base=${file%-expected_eps.$extension}_eps
373373
elif [[ $file == *"-expected_svg"* ]]; then
374374
base=${file%-expected_svg.$extension}_svg
375+
elif [[ $file == *"-expected_gif"* ]]; then
376+
base=${file%-expected_gif.$extension}_gif
375377
else
376378
base=${file%-expected.$extension}
377379
fi
@@ -388,7 +390,7 @@ jobs:
388390
done
389391
}
390392
391-
remove_files "png"; remove_files "svg"; remove_files "pdf"; remove_files "eps";
393+
remove_files "png"; remove_files "svg"; remove_files "pdf"; remove_files "eps"; remove_files "gif";
392394
393395
if [ "$(find ./result_images -mindepth 1 -type d)" ]; then
394396
find ./result_images/* -type d -empty -delete

doc/api/colors_api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Color norms
2121
:toctree: _as_gen/
2222
:template: autosummary.rst
2323

24+
Norm
2425
Normalize
2526
NoNorm
2627
AsinhNorm
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
``matplotlib.style.core``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~
3+
The ``matplotlib.style.core`` module is deprecated. All APIs intended for
4+
public use are now available in `matplotlib.style` directly (including
5+
``USER_LIBRARY_PATHS``, which was previously not reexported).
6+
7+
The following APIs of ``matplotlib.style.core`` have been deprecated with no
8+
replacement: ``BASE_LIBRARY_PATH``, ``STYLE_EXTENSION``, ``STYLE_BLACKLIST``,
9+
``update_user_library``, ``read_style_directory``, ``update_nested_dict``.

doc/api/prev_api_changes/api_changes_3.5.0/deprecations.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ Miscellaneous deprecations
282282
- The *format* parameter of ``dviread.find_tex_file`` is deprecated (with no
283283
replacement).
284284
- ``FancyArrowPatch.get_path_in_displaycoord`` and
285-
``ConnectionPath.get_path_in_displaycoord`` are deprecated. The path in
285+
``ConnectionPatch.get_path_in_displaycoord`` are deprecated. The path in
286286
display coordinates can still be obtained, as for other patches, using
287287
``patch.get_transform().transform_path(patch.get_path())``.
288288
- The ``font_manager.win32InstalledFonts`` and

doc/api/prev_api_changes/api_changes_3.7.0/removals.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ Miscellaneous removals
323323
- The *format* parameter of ``dviread.find_tex_file`` is removed (with no
324324
replacement).
325325
- ``FancyArrowPatch.get_path_in_displaycoord`` and
326-
``ConnectionPath.get_path_in_displaycoord`` are removed. The path in
326+
``ConnectionPatch.get_path_in_displaycoord`` are removed. The path in
327327
display coordinates can still be obtained, as for other patches, using
328328
``patch.get_transform().transform_path(patch.get_path())``.
329329
- The ``font_manager.win32InstalledFonts`` and

doc/devel/tag_guidelines.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Proposing new tags
6161
1. Review existing tag list, looking out for similar entries (i.e. ``axes`` and ``axis``).
6262
2. If a relevant tag or subcategory does not yet exist, propose it. Each tag is two
6363
parts: ``subcategory: tag``. Tags should be one or two words.
64-
3. New tags should be be added when they are relevant to existing gallery entries too.
64+
3. New tags should be added when they are relevant to existing gallery entries too.
6565
Avoid tags that will link to only a single gallery entry.
6666
4. Tags can recreate other forms of organization.
6767

doc/project/history.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Matplotlib logo (2008 - 2015).
157157

158158

159159
def add_math_background():
160-
ax = fig.add_axes([0., 0., 1., 1.])
160+
ax = fig.add_axes((0., 0., 1., 1.))
161161

162162
text = []
163163
text.append(
@@ -187,7 +187,7 @@ Matplotlib logo (2008 - 2015).
187187

188188

189189
def add_polar_bar():
190-
ax = fig.add_axes([0.025, 0.075, 0.2, 0.85], projection='polar')
190+
ax = fig.add_axes((0.025, 0.075, 0.2, 0.85), projection='polar')
191191

192192
ax.patch.set_alpha(axalpha)
193193
ax.set_axisbelow(True)

doc/users/faq.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,23 @@ locators as desired because the two axes are independent.
281281
Generate images without having a window appear
282282
----------------------------------------------
283283

284-
Simply do not call `~matplotlib.pyplot.show`, and directly save the figure to
285-
the desired format::
284+
The recommended approach since matplotlib 3.1 is to explicitly create a Figure
285+
instance::
286+
287+
from matplotlib.figure import Figure
288+
fig = Figure()
289+
ax = fig.subplots()
290+
ax.plot([1, 2, 3])
291+
fig.savefig('myfig.png')
292+
293+
This prevents any interaction with GUI frameworks and the window manager.
294+
295+
It's alternatively still possible to use the pyplot interface. Instead of
296+
calling `matplotlib.pyplot.show`, call `matplotlib.pyplot.savefig`.
297+
298+
Additionally, you must ensure to close the figure after saving it. Not
299+
closing the figure is a memory leak, because pyplot keeps references
300+
to all not-yet-shown figures::
286301

287302
import matplotlib.pyplot as plt
288303
plt.plot([1, 2, 3])
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Separate styling options for major/minor grid line in rcParams
2+
--------------------------------------------------------------
3+
4+
Using :rc:`grid.major.*` or :rc:`grid.minor.*` will overwrite the value in
5+
:rc:`grid.*` for the major and minor gridlines, respectively.
6+
7+
.. plot::
8+
:include-source: true
9+
:alt: Modifying the gridlines using the new options `rcParams`
10+
11+
import matplotlib as mpl
12+
import matplotlib.pyplot as plt
13+
14+
15+
# Set visibility for major and minor gridlines
16+
mpl.rcParams["axes.grid"] = True
17+
mpl.rcParams["ytick.minor.visible"] = True
18+
mpl.rcParams["xtick.minor.visible"] = True
19+
mpl.rcParams["axes.grid.which"] = "both"
20+
21+
# Using old values to set both major and minor properties
22+
mpl.rcParams["grid.color"] = "red"
23+
mpl.rcParams["grid.linewidth"] = 1
24+
25+
# Overwrite some values for major and minor separately
26+
mpl.rcParams["grid.major.color"] = "black"
27+
mpl.rcParams["grid.major.linewidth"] = 2
28+
mpl.rcParams["grid.minor.linestyle"] = ":"
29+
mpl.rcParams["grid.minor.alpha"] = 0.6
30+
31+
plt.plot([0, 1], [0, 1])
32+
33+
plt.show()

doc/users/prev_whats_new/dflt_style_changes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ a cleaner separation between subplots.
10051005

10061006
ax = fig.add_subplot(2, 2, j)
10071007
ax.hist(np.random.beta(0.5, 0.5, 10000), 25, density=True)
1008-
ax.set_xlim([0, 1])
1008+
ax.set_xlim(0, 1)
10091009
ax.set_title(title)
10101010

10111011
ax = fig.add_subplot(2, 2, j + 2)

doc/users/prev_whats_new/whats_new_3.5.0.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,9 @@ of the text inside the Axes of the `.TextBox` widget.
274274

275275
fig = plt.figure(figsize=(4, 3))
276276
for i, alignment in enumerate(['left', 'center', 'right']):
277-
box_input = fig.add_axes([0.1, 0.7 - i*0.3, 0.8, 0.2])
278-
text_box = TextBox(ax=box_input, initial=f'{alignment} alignment',
279-
label='', textalignment=alignment)
277+
box_input = fig.add_axes((0.1, 0.7 - i*0.3, 0.8, 0.2))
278+
text_box = TextBox(ax=box_input, initial=f'{alignment} alignment',
279+
label='', textalignment=alignment)
280280

281281
Simplifying the font setting for usetex mode
282282
--------------------------------------------
@@ -375,9 +375,9 @@ attribute.
375375
points = ax.scatter((3, 3), (1, 3), (1, 3), c='red', zorder=10,
376376
label='zorder=10')
377377

378-
ax.set_xlim((0, 5))
379-
ax.set_ylim((0, 5))
380-
ax.set_zlim((0, 2.5))
378+
ax.set_xlim(0, 5)
379+
ax.set_ylim(0, 5)
380+
ax.set_zlim(0, 2.5)
381381

382382
plane = mpatches.Patch(facecolor='white', edgecolor='black',
383383
label='zorder=1')
@@ -485,7 +485,7 @@ new styling parameters for the added handles.
485485
ax = ax_old
486486
valmin = 0
487487
valinit = 0.5
488-
ax.set_xlim([0, 1])
488+
ax.set_xlim(0, 1)
489489
ax_old.axvspan(valmin, valinit, 0, 1)
490490
ax.axvline(valinit, 0, 1, color="r", lw=1)
491491
ax.set_xticks([])

doc/users/prev_whats_new/whats_new_3.8.0.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ The following delimiter names have been supported earlier, but can now be sized
359359
* ``\leftparen`` and ``\rightparen``
360360

361361
There are really no obvious advantages in using these.
362-
Instead, they are are added for completeness.
362+
Instead, they are added for completeness.
363363

364364
``mathtext`` documentation improvements
365365
---------------------------------------
@@ -513,7 +513,7 @@ Plot Directive now can make responsive images with "srcset"
513513

514514
The plot sphinx directive (``matplotlib.sphinxext.plot_directive``, invoked in
515515
rst as ``.. plot::``) can be configured to automatically make higher res
516-
figures and add these to the the built html docs. In ``conf.py``::
516+
figures and add these to the built html docs. In ``conf.py``::
517517

518518
extensions = [
519519
...

galleries/examples/animation/rain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
# Create new Figure and an Axes which fills it.
2424
fig = plt.figure(figsize=(7, 7))
25-
ax = fig.add_axes([0, 0, 1, 1], frameon=False)
25+
ax = fig.add_axes((0, 0, 1, 1), frameon=False)
2626
ax.set_xlim(0, 1), ax.set_xticks([])
2727
ax.set_ylim(0, 1), ax.set_yticks([])
2828

galleries/examples/animation/simple_scatter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import matplotlib.animation as animation
1212

1313
fig, ax = plt.subplots()
14-
ax.set_xlim([0, 10])
14+
ax.set_xlim(0, 10)
1515

1616
scat = ax.scatter(1, 0)
1717
x = np.linspace(0, 10)

galleries/examples/axes_grid1/make_room_for_ylabel_using_axesgrid.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from mpl_toolkits.axes_grid1.axes_divider import make_axes_area_auto_adjustable
1111

1212
fig = plt.figure()
13-
ax = fig.add_axes([0, 0, 1, 1])
13+
ax = fig.add_axes((0, 0, 1, 1))
1414

1515
ax.set_yticks([0.5], labels=["very long label"])
1616

@@ -19,8 +19,8 @@
1919
# %%
2020

2121
fig = plt.figure()
22-
ax1 = fig.add_axes([0, 0, 1, 0.5])
23-
ax2 = fig.add_axes([0, 0.5, 1, 0.5])
22+
ax1 = fig.add_axes((0, 0, 1, 0.5))
23+
ax2 = fig.add_axes((0, 0.5, 1, 0.5))
2424

2525
ax1.set_yticks([0.5], labels=["very long label"])
2626
ax1.set_ylabel("Y label")
@@ -33,7 +33,7 @@
3333
# %%
3434

3535
fig = plt.figure()
36-
ax1 = fig.add_axes([0, 0, 1, 1])
36+
ax1 = fig.add_axes((0, 0, 1, 1))
3737
divider = make_axes_locatable(ax1)
3838

3939
ax2 = divider.append_axes("right", "100%", pad=0.3, sharey=ax1)

galleries/examples/axisartist/demo_parasite_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
fig = plt.figure()
2626

27-
host = fig.add_axes([0.15, 0.1, 0.65, 0.8], axes_class=HostAxes)
27+
host = fig.add_axes((0.15, 0.1, 0.65, 0.8), axes_class=HostAxes)
2828
par1 = host.get_aux_axes(viewlim_mode=None, sharex=host)
2929
par2 = host.get_aux_axes(viewlim_mode=None, sharex=host)
3030

galleries/examples/event_handling/poly_editor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,6 @@ def on_mouse_move(self, event):
203203
p = PolygonInteractor(ax, poly)
204204

205205
ax.set_title('Click and drag a point to move it')
206-
ax.set_xlim((-2, 2))
207-
ax.set_ylim((-2, 2))
206+
ax.set_xlim(-2, 2)
207+
ax.set_ylim(-2, 2)
208208
plt.show()

galleries/examples/event_handling/pong_sgskip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ def __init__(self, ax):
134134
# create the initial line
135135
self.ax = ax
136136
ax.xaxis.set_visible(False)
137-
ax.set_xlim([0, 7])
137+
ax.set_xlim(0, 7)
138138
ax.yaxis.set_visible(False)
139-
ax.set_ylim([-1, 1])
139+
ax.set_ylim(-1, 1)
140140
pad_a_x = 0
141141
pad_b_x = .50
142142
pad_a_y = pad_b_y = .30

galleries/examples/images_contours_and_fields/barcode_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
dpi = 100
3131

3232
fig = plt.figure(figsize=(len(code) * pixel_per_bar / dpi, 2), dpi=dpi)
33-
ax = fig.add_axes([0, 0, 1, 1]) # span the whole figure
33+
ax = fig.add_axes((0, 0, 1, 1)) # span the whole figure
3434
ax.set_axis_off()
3535
ax.imshow(code.reshape(1, -1), cmap='binary', aspect='auto',
3636
interpolation='nearest')

galleries/examples/images_contours_and_fields/image_antialiasing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@
245245
# may serve a 100x100 version of the image, which will be downsampled.)
246246

247247
fig = plt.figure(figsize=(2, 2))
248-
ax = fig.add_axes([0, 0, 1, 1])
248+
ax = fig.add_axes((0, 0, 1, 1))
249249
ax.imshow(aa[:400, :400], cmap='RdBu_r', interpolation='nearest')
250250
plt.show()
251251
# %%

galleries/examples/images_contours_and_fields/image_exact_placement.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ def annotate_rect(ax):
134134
fig = plt.figure(figsize=(fig_width / dpi, fig_height / dpi), facecolor='aliceblue')
135135

136136
# the position posA must be normalized by the figure width and height:
137-
ax = fig.add_axes([posA[0] / fig_width, posA[1] / fig_height,
138-
posA[2] / fig_width, posA[3] / fig_height])
137+
ax = fig.add_axes((posA[0] / fig_width, posA[1] / fig_height,
138+
posA[2] / fig_width, posA[3] / fig_height))
139139
ax.imshow(A, vmin=-1, vmax=1)
140140
annotate_rect(ax)
141141

142-
ax = fig.add_axes([posB[0] / fig_width, posB[1] / fig_height,
143-
posB[2] / fig_width, posB[3] / fig_height])
142+
ax = fig.add_axes((posB[0] / fig_width, posB[1] / fig_height,
143+
posB[2] / fig_width, posB[3] / fig_height))
144144
ax.imshow(B, vmin=-1, vmax=1)
145145
plt.show()
146146
# %%

0 commit comments

Comments
 (0)