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

Skip to content

Commit 67b504d

Browse files
authored
Merge branch 'matplotlib:main' into tk_toolbar_tooltips
2 parents 8fe6ba5 + 0548b11 commit 67b504d

File tree

79 files changed

+846
-694
lines changed

Some content is hidden

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

79 files changed

+846
-694
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ per-file-ignores =
100100
tutorials/introductory/images.py: E402, E501
101101
tutorials/introductory/pyplot.py: E402, E501
102102
tutorials/introductory/sample_plots.py: E501
103-
tutorials/introductory/usage.py: E703
103+
tutorials/introductory/quick_start.py: E703
104104
tutorials/text/annotations.py: E402, E501
105105
tutorials/text/text_intro.py: E402
106106
tutorials/text/text_props.py: E501

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99

1010
env:
1111
NO_AT_BRIDGE: 1 # Necessary for GTK3 interactive test.
12+
NPY_DISABLE_CPU_FEATURES: "AVX512F,AVX512CD,AVX512VL,AVX512BW,AVX512DQ,AVX512_SKX"
1213
OPENBLAS_NUM_THREADS: 1
1314
PYTHONFAULTHANDLER: 1
1415

azure-pipelines.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ stages:
129129
displayName: 'print env'
130130

131131
- bash: |
132+
export NPY_DISABLE_CPU_FEATURES="AVX512F,AVX512CD,AVX512VL,AVX512BW,AVX512DQ,AVX512_SKX"
132133
PYTHONFAULTHANDLER=1 python -m pytest --junitxml=junit/test-results.xml -raR --maxfail=50 --timeout=300 --durations=25 --cov-report= --cov=lib -n 2 ||
133134
[[ "$PYTHON_VERSION" = 'Pre' ]]
134135
displayName: 'pytest'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
3D contourf polygons placed between levels
22
------------------------------------------
3-
The polygons used in a 3D `~mpl_toolkits.mplot3d.Axes3D.contourf` plot are
3+
The polygons used in a 3D `~.Axes3D.contourf` plot are
44
now placed halfway between the contour levels, as each polygon represents the
55
location of values that lie between two levels.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Move Axes title to not overlap with y axis offset
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
Previously, Axes titles could overlap the y-axis offset text, which is often
5+
in the upper left corner of the axes. Now titles are moved above the offset
6+
text if overlapping, and autopositioning is in effect (i.e. if *y* in
7+
`.Axes.set_title` is *None* and :rc:`axes.titley` is also *None*).
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Removal of mplot3d deprecations
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
The deprecated ``renderer`` arguments have been removed from:
4+
5+
- `.Line3DCollection.do_3d_projection`
6+
- `.Patch3D.do_3d_projection`
7+
- `.PathPatch3D.do_3d_projection`
8+
- `.Path3DCollection.do_3d_projection`
9+
- `.Patch3DCollection.do_3d_projection`
10+
- `.Poly3DCollection.do_3d_projection`
11+
12+
The deprecated ``project`` argument has also been removed from
13+
``Line3DCollection.draw()``.
14+
15+
Passing arguments not specifically listed in the signatures of
16+
`.Axes3D.plot_surface` and `.Axes3D.plot_wireframe` is no longer supported.
17+
Pass any extra arguments as keyword arguments instead.
18+
19+
These properties of the 3D Axes that were placed on the Renderer during draw
20+
have been removed:
21+
22+
* ``renderer.M``
23+
* ``renderer.eye``
24+
* ``renderer.vvec``
25+
* ``renderer.get_axis_position``
26+
27+
These attributes are all available via `.Axes3D`, which can be accessed via
28+
``self.axes`` on all `.Artist`\s.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
colorbar defaults to stealing space from the mappable's axes rather than the current axes
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
Pass ``ax=plt.gca()`` to restore the previous behavior.
5+
6+
Removal of deprecated ``colorbar`` APIs
7+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8+
9+
The following deprecated :mod:`.colorbar` APIs have been removed:
10+
``ColorbarPatch`` and ``colorbar_factory`` (use `.Colorbar` instead);
11+
``colorbar_doc``, ``colorbar_kw_doc``, ``make_axes_kw_doc``.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,13 @@ yet parsed, but this is a prerequisite for implementing subsetting.
235235
3D contourf polygons placed between levels
236236
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
237237

238-
The polygons used in a 3D `~mpl_toolkits.mplot3d.Axes3D.contourf` plot are now
238+
The polygons used in a 3D `~.Axes3D.contourf` plot are now
239239
placed halfway between the contour levels, as each polygon represents the
240240
location of values that lie between two levels.
241241

242242
``AxesDivider`` now defaults to rcParams-specified pads
243243
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
244244

245-
`.AxesDivider.append_axes`, `.AxesDivider.new_horizontal`, and
246-
`.AxesDivider.new_vertical` now default to paddings specified by
245+
`.AxesDivider.append_axes`, ``AxesDivider.new_horizontal``, and
246+
``AxesDivider.new_vertical`` now default to paddings specified by
247247
:rc:`figure.subplot.wspace` and :rc:`figure.subplot.hspace` rather than zero.

doc/devel/contributing.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ Introducing
326326
All these helpers take a first parameter *since*, which should be set to
327327
the next point release, e.g. "3.x".
328328

329+
You can use standard rst cross references in *alternative*.
330+
329331
Expiring
330332
~~~~~~~~
331333

doc/devel/documenting_mpl.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,15 @@ Documents can be linked with the ``:doc:`` directive:
199199
200200
See the :doc:`/users/installing/index`
201201
202-
See the tutorial :doc:`/tutorials/introductory/usage`
202+
See the tutorial :doc:`/tutorials/introductory/quick_start`
203203
204204
See the example :doc:`/gallery/lines_bars_and_markers/simple_plot`
205205
206206
will render as:
207207

208208
See the :doc:`/users/installing/index`
209209

210-
See the tutorial :doc:`/tutorials/introductory/usage`
210+
See the tutorial :doc:`/tutorials/introductory/quick_start`
211211

212212
See the example :doc:`/gallery/lines_bars_and_markers/simple_plot`
213213

@@ -847,7 +847,7 @@ render as comments in :doc:`/gallery/lines_bars_and_markers/simple_plot`.
847847

848848
Tutorials are made with the exact same mechanism, except they are longer, and
849849
typically have more than one comment block (i.e.
850-
:doc:`/tutorials/introductory/usage`). The first comment block
850+
:doc:`/tutorials/introductory/quick_start`). The first comment block
851851
can be the same as the example above. Subsequent blocks of ReST text
852852
are delimited by a line of ``###`` characters:
853853

doc/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Learning resources
4646
Tutorials
4747
^^^^^^^^^
4848

49-
- :doc:`Quick-start guide <tutorials/introductory/usage>`
49+
- :doc:`Quick-start guide <tutorials/introductory/quick_start>`
5050
- :doc:`Plot types <plot_types/index>`
5151
- `Introductory tutorials <../tutorials/index.html#introductory>`_
5252
- :doc:`External learning resources <users/resources/index>`
@@ -56,7 +56,7 @@ Learning resources
5656
How-tos
5757
^^^^^^^
5858
- :doc:`Example gallery <gallery/index>`
59-
- :doc:`Matplotlib FAQ <faq/index>`
59+
- :doc:`Matplotlib FAQ <users/faq/index>`
6060

6161
---
6262

doc/users/getting_started/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ Here is a minimal example plot:
4444
ax.plot(x, y)
4545
plt.show()
4646

47-
If a plot does not show up please check :ref:`troubleshooting-faq`.
47+
If a plot does not show up please check :ref:`troubleshooting-faq`.
4848

4949
Where to go next
5050
----------------
5151

5252
- Check out :doc:`Plot types </plot_types/index>` to get an overview of the
5353
types of plots you can create with Matplotlib.
5454
- Learn Matplotlib from the ground up in the
55-
:doc:`Quick-start guide </tutorials/introductory/usage>`.
55+
:doc:`Quick-start guide </tutorials/introductory/quick_start>`.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
``math_to_image`` now has a *color* keyword argument
2+
--------------------------------------------------------
3+
4+
To easily support external libraries that rely on the MathText rendering of
5+
Matplotlib to generate equation images, a *color* keyword argument was added
6+
to `~matplotlib.mathtext.math_to_image`.
7+
8+
.. code-block:: python
9+
10+
from matplotlib import mathtext
11+
mathtext.math_to_image('$x^2$', 'filename.png', color='Maroon')
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
PolygonSelector bounding boxes
2+
------------------------------
3+
`~matplotlib.widgets.PolygonSelector` now has a *draw_bounding_box* argument, which
4+
when set to `True` will draw a bounding box around the polygon once it is
5+
complete. The bounding box can be resized and moved, allowing the points of
6+
the polygon to be easily resized.

doc/users/prev_whats_new/whats_new_1.4.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ Simple quiver plot for mplot3d toolkit
242242
A team of students in an *Engineering Large Software Systems* course, taught
243243
by Prof. Anya Tafliovich at the University of Toronto, implemented a simple
244244
version of a quiver plot in 3D space for the mplot3d toolkit as one of their
245-
term project. This feature is documented in :func:`~mpl_toolkits.mplot3d.Axes3D.quiver`.
245+
term project. This feature is documented in `~.Axes3D.quiver`.
246246
The team members are: Ryan Steve D'Souza, Victor B, xbtsw, Yang Wang, David,
247247
Caradec Bisesar and Vlad Vassilovski.
248248

doc/users/prev_whats_new/whats_new_1.5.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ Added a :mod:`.legend_handler` for :class:`~matplotlib.collections.PolyCollectio
340340
Support for alternate pivots in mplot3d quiver plot
341341
```````````````````````````````````````````````````
342342

343-
Added a :code:`pivot` kwarg to :func:`~mpl_toolkits.mplot3d.Axes3D.quiver`
343+
Added a :code:`pivot` kwarg to `~.Axes3D.quiver`
344344
that controls the pivot point around which the quiver line rotates. This also
345345
determines the placement of the arrow head along the quiver line.
346346

doc/users/resources/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@ Tutorials
7777
* `Anatomy of Matplotlib - IPython Notebooks
7878
<https://github.com/WeatherGod/AnatomyOfMatplotlib>`_
7979
by Benjamin Root
80+
81+
* `Beyond the Basics: Data Visualization in Python
82+
<https://github.com/stefmolin/python-data-viz-workshop>`_
83+
by Stefanie Molin

environment.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ dependencies:
2929
- numpydoc>=0.8
3030
- packaging
3131
- pydata-sphinx-theme
32-
- scipy
3332
- sphinx>=1.8.1,!=2.0.0
3433
- sphinx-copybutton
3534
- sphinx-gallery>=0.10

examples/animation/double_pendulum.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from numpy import sin, cos
1313
import numpy as np
1414
import matplotlib.pyplot as plt
15-
import scipy.integrate as integrate
1615
import matplotlib.animation as animation
1716
from collections import deque
1817

@@ -22,13 +21,13 @@
2221
L = L1 + L2 # maximal length of the combined pendulum
2322
M1 = 1.0 # mass of pendulum 1 in kg
2423
M2 = 1.0 # mass of pendulum 2 in kg
25-
t_stop = 5 # how many seconds to simulate
24+
t_stop = 2.5 # how many seconds to simulate
2625
history_len = 500 # how many trajectory points to display
2726

2827

29-
def derivs(state, t):
30-
28+
def derivs(t, state):
3129
dydx = np.zeros_like(state)
30+
3231
dydx[0] = state[1]
3332

3433
delta = state[2] - state[0]
@@ -51,7 +50,7 @@ def derivs(state, t):
5150
return dydx
5251

5352
# create a time array from 0..t_stop sampled at 0.02 second steps
54-
dt = 0.02
53+
dt = 0.01
5554
t = np.arange(0, t_stop, dt)
5655

5756
# th1 and th2 are the initial angles (degrees)
@@ -64,8 +63,15 @@ def derivs(state, t):
6463
# initial state
6564
state = np.radians([th1, w1, th2, w2])
6665

67-
# integrate your ODE using scipy.integrate.
68-
y = integrate.odeint(derivs, state, t)
66+
# integrate the ODE using Euler's method
67+
y = np.empty((len(t), 4))
68+
y[0] = state
69+
for i in range(1, len(t)):
70+
y[i] = y[i - 1] + derivs(t[i - 1], y[i - 1]) * dt
71+
72+
# A more accurate estimate could be obtained e.g. using scipy:
73+
#
74+
# y = scipy.integrate.solve_ivp(derivs, t[[0, -1]], state, t_eval=t).y.T
6975

7076
x1 = L1*sin(y[:, 0])
7177
y1 = -L1*cos(y[:, 0])

examples/axes_grid1/demo_axes_divider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def demo_locatable_axes_easy(ax):
6868

6969
divider = make_axes_locatable(ax)
7070

71-
ax_cb = divider.new_horizontal(size="5%", pad=0.05)
71+
ax_cb = divider.append_axes("right", size="5%", pad=0.05)
7272
fig = ax.get_figure()
7373
fig.add_axes(ax_cb)
7474

@@ -86,7 +86,7 @@ def demo_images_side_by_side(ax):
8686
divider = make_axes_locatable(ax)
8787

8888
Z, extent = get_demo_image()
89-
ax2 = divider.new_horizontal(size="100%", pad=0.05)
89+
ax2 = divider.append_axes("right", size="100%", pad=0.05)
9090
fig1 = ax.get_figure()
9191
fig1.add_axes(ax2)
9292

examples/axes_grid1/make_room_for_ylabel_using_axesgrid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
ax1 = plt.axes([0, 0, 1, 1])
4141
divider = make_axes_locatable(ax1)
4242

43-
ax2 = divider.new_horizontal("100%", pad=0.3, sharey=ax1)
43+
ax2 = divider.append_axes("right", "100%", pad=0.3, sharey=ax1)
4444
ax2.tick_params(labelleft=False)
4545
fig.add_axes(ax2)
4646

examples/lines_bars_and_markers/lines_with_ticks_demo.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
import matplotlib.pyplot as plt
1616
from matplotlib import patheffects
1717

18+
# Plot a straight diagonal line with ticked style path
1819
fig, ax = plt.subplots(figsize=(6, 6))
1920
ax.plot([0, 1], [0, 1], label="Line",
2021
path_effects=[patheffects.withTickedStroke(spacing=7, angle=135)])
2122

23+
# Plot a curved line with ticked style path
2224
nx = 101
2325
x = np.linspace(0.0, 1.0, nx)
2426
y = 0.3*np.sin(x*8) + 0.4

examples/lines_bars_and_markers/scatter_demo2.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
import matplotlib.pyplot as plt
1010
import matplotlib.cbook as cbook
1111

12-
# Load a numpy record array from yahoo csv data with fields date, open, close,
13-
# volume, adj_close from the mpl-data/example directory. The record array
14-
# stores the date as an np.datetime64 with a day unit ('D') in the date column.
12+
# Load a numpy record array from yahoo csv data with fields date, open, high,
13+
# low, close, volume, adj_close from the mpl-data/sample_data directory. The
14+
# record array stores the date as an np.datetime64 with a day unit ('D') in
15+
# the date column.
1516
price_data = (cbook.get_sample_data('goog.npz', np_load=True)['price_data']
1617
.view(np.recarray))
1718
price_data = price_data[-250:] # get the most recent 250 trading days

examples/mplot3d/lorenz_attractor.py

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,45 +18,41 @@
1818
import matplotlib.pyplot as plt
1919

2020

21-
def lorenz(x, y, z, s=10, r=28, b=2.667):
21+
def lorenz(xyz, *, s=10, r=28, b=2.667):
2222
"""
23-
Given:
24-
x, y, z: a point of interest in three dimensional space
25-
s, r, b: parameters defining the lorenz attractor
26-
Returns:
27-
x_dot, y_dot, z_dot: values of the lorenz attractor's partial
28-
derivatives at the point x, y, z
23+
Parameters
24+
----------
25+
xyz : array-like, shape (3,)
26+
Point of interest in three dimensional space.
27+
s, r, b : float
28+
Parameters defining the Lorenz attractor.
29+
30+
Returns
31+
-------
32+
xyz_dot : array, shape (3,)
33+
Values of the Lorenz attractor's partial derivatives at *xyz*.
2934
"""
35+
x, y, z = xyz
3036
x_dot = s*(y - x)
3137
y_dot = r*x - y - x*z
3238
z_dot = x*y - b*z
33-
return x_dot, y_dot, z_dot
39+
return np.array([x_dot, y_dot, z_dot])
3440

3541

3642
dt = 0.01
3743
num_steps = 10000
3844

39-
# Need one more for the initial values
40-
xs = np.empty(num_steps + 1)
41-
ys = np.empty(num_steps + 1)
42-
zs = np.empty(num_steps + 1)
43-
44-
# Set initial values
45-
xs[0], ys[0], zs[0] = (0., 1., 1.05)
46-
45+
xyzs = np.empty((num_steps + 1, 3)) # Need one more for the initial values
46+
xyzs[0] = (0., 1., 1.05) # Set initial values
4747
# Step through "time", calculating the partial derivatives at the current point
4848
# and using them to estimate the next point
4949
for i in range(num_steps):
50-
x_dot, y_dot, z_dot = lorenz(xs[i], ys[i], zs[i])
51-
xs[i + 1] = xs[i] + (x_dot * dt)
52-
ys[i + 1] = ys[i] + (y_dot * dt)
53-
zs[i + 1] = zs[i] + (z_dot * dt)
54-
50+
xyzs[i + 1] = xyzs[i] + lorenz(xyzs[i]) * dt
5551

5652
# Plot
5753
ax = plt.figure().add_subplot(projection='3d')
5854

59-
ax.plot(xs, ys, zs, lw=0.5)
55+
ax.plot(*xyzs.T, lw=0.5)
6056
ax.set_xlabel("X Axis")
6157
ax.set_ylabel("Y Axis")
6258
ax.set_zlabel("Z Axis")

0 commit comments

Comments
 (0)