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

Skip to content

Commit 1503ed5

Browse files
committed
Merge branch 'hasans-matplotlib/main' of https://github.com/hasanrashid/matplotlib into hasans-matplotlib/main
2 parents d3bf57d + cb59251 commit 1503ed5

Some content is hidden

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

64 files changed

+682
-338
lines changed

.circleci/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ jobs:
234234

235235
- add_ssh_keys:
236236
fingerprints:
237-
- "6b:83:76:a5:7d:bd:ce:19:a4:e3:81:e0:80:16:a4:fe"
237+
- "be:c3:c1:d8:fb:a1:0e:37:71:72:d7:a3:40:13:8f:14"
238+
238239
- deploy:
239240
name: "Deploy new docs"
240241
command: ./.circleci/deploy-docs.sh
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
``contour`` and ``contourf`` auto-select suitable levels when given boolean inputs
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
If the height array given to `.Axes.contour` or `.Axes.contourf` is of bool
4+
dtype and *levels* is not specified, *levels* now defaults to ``[0.5]`` for
5+
`~.Axes.contour` and ``[0, 0.5, 1]`` for `.Axes.contourf`.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``AxesImage.set_extent`` now raises ``TypeError`` for unknown keyword arguments
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
It previously raised a `ValueError`.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``passthru_pt``
2+
~~~~~~~~~~~~~~~
3+
This attribute of ``AxisArtistHelper``\s is deprecated.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
``BrokenBarHCollection`` is deprecated
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
It was just a thin wrapper inheriting from `.PolyCollection`;
4+
`~.Axes.broken_barh` has now been changed to return a `.PolyCollection`
5+
instead.
6+
7+
The ``BrokenBarHCollection.span_where`` helper is likewise deprecated; for the
8+
duration of the deprecation it has been moved to the parent `.PolyCollection`
9+
class. Use `~.Axes.fill_between` as a replacement; see
10+
:doc:`/gallery/lines_bars_and_markers/span_regions` for an example.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
numpy>=1.20 is now required
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~

doc/devel/dependencies.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ reference.
2121
* `dateutil <https://pypi.org/project/python-dateutil/>`_ (>= 2.7)
2222
* `fontTools <https://fonttools.readthedocs.io/en/latest/>`_ (>= 4.22.0)
2323
* `kiwisolver <https://github.com/nucleic/kiwi>`_ (>= 1.0.1)
24-
* `NumPy <https://numpy.org>`_ (>= 1.19)
24+
* `NumPy <https://numpy.org>`_ (>= 1.20)
2525
* `packaging <https://pypi.org/project/packaging/>`_ (>= 20.0)
2626
* `Pillow <https://pillow.readthedocs.io/en/latest/>`_ (>= 6.2)
2727
* `pyparsing <https://pypi.org/project/pyparsing/>`_ (>= 2.3.1)
@@ -203,7 +203,7 @@ Setup dependencies
203203
- `setuptools_scm <https://pypi.org/project/setuptools-scm/>`_ (>= 7). Used to
204204
update the reported ``mpl.__version__`` based on the current git commit.
205205
Also a runtime dependency for editable installs.
206-
- `NumPy <https://numpy.org>`_ (>= 1.19). Also a runtime dependency.
206+
- `NumPy <https://numpy.org>`_ (>= 1.20). Also a runtime dependency.
207207

208208

209209
.. _compile-dependencies:

doc/devel/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ process or how to fix something feel free to ask on `gitter
4545

4646
.. rst-class:: sd-d-inline-block
4747

48-
.. button-ref:: contributing_documentation
48+
.. button-ref:: documenting-matplotlib
4949
:class: sd-fs-6
5050
:color: primary
5151

doc/devel/min_dep_policy.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ specification of the dependencies.
8787
========== ======== ======
8888
Matplotlib Python NumPy
8989
========== ======== ======
90+
`3.7`_ 3.8 1.20.0
9091
`3.6`_ 3.8 1.19.0
9192
`3.5`_ 3.7 1.17.0
9293
`3.4`_ 3.7 1.16.0
@@ -105,6 +106,7 @@ Matplotlib Python NumPy
105106
1.0 2.4 1.1
106107
========== ======== ======
107108

109+
.. _`3.7`: https://matplotlib.org/3.7.0/devel/dependencies.html
108110
.. _`3.6`: https://matplotlib.org/3.6.0/devel/dependencies.html
109111
.. _`3.5`: https://matplotlib.org/3.5.0/devel/dependencies.html
110112
.. _`3.4`: https://matplotlib.org/3.4.0/devel/dependencies.html

doc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Installation
3232

3333
.. code-block:: bash
3434
35-
conda install matplotlib
35+
conda install -c conda-forge matplotlib
3636
3737
Further details are available in the :doc:`Installation Guide <users/installing/index>`.
3838

doc/sphinxext/redirect_from.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def merge_domaindata(self, docnames, otherdata):
8383
elif self.redirects[src] != dst:
8484
raise ValueError(
8585
f"Inconsistent redirections from {src} to "
86-
F"{self.redirects[src]} and {otherdata.redirects[src]}")
86+
f"{self.redirects[src]} and {otherdata['redirects'][src]}")
8787

8888

8989
class RedirectFrom(Directive):

doc/users/getting_started/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Installation quick-start
2020

2121
.. code-block:: bash
2222
23-
conda install matplotlib
23+
conda install -c conda-forge matplotlib
2424
2525
Further details are available in the :doc:`Installation Guide </users/installing/index>`.
2626

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
New & Improved Narrative Documentation
2+
======================================
3+
* Brand new :doc:`Animations </tutorials/introductory/animation_tutorial>` tutorial.
4+
* New grouped and stacked `bar chart <../../gallery/index.html#lines_bars_and_markers>`_ examples.
5+
* New section for new contributors and reorganized git instructions in the :ref:`contributing guide<contributing>`.
6+
* Restructured :doc:`/tutorials/text/annotations` tutorial.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Figure legends can be placed outside figures using constrained_layout
2+
---------------------------------------------------------------------
3+
Constrained layout will make space for Figure legends if they are specified
4+
by a *loc* keyword argument that starts with the string "outside". The
5+
codes are unique from axes codes, in that "outside upper right" will
6+
make room at the top of the figure for the legend, whereas
7+
"outside right upper" will make room on the right-hand side of the figure.
8+
See :doc:`/tutorials/intermediate/legend_guide` for details.

doc/users/next_whats_new/per_subplot_mosaic.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
``subplot_mosaic`` no longer provisional
2+
----------------------------------------
3+
4+
The API on `.Figure.subplot_mosaic` and `.pyplot.subplot_mosaic` are now
5+
considered stable and will change under Matplotlib's normal deprecation
6+
process.
7+
8+
19
Per-subplot keyword arguments in ``subplot_mosaic``
210
----------------------------------------------------
311

doc/users/prev_whats_new/whats_new_3.3.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ or as a string (with single-character Axes labels):
5050
ha='center', va='center', fontsize=36,
5151
color='darkgrey')
5252

53-
See :doc:`/tutorials/provisional/mosaic` for more details and examples.
53+
See :doc:`/gallery/subplots_axes_and_figures/mosaic` for more details and examples.
5454

5555
``GridSpec.subplots()``
5656
-----------------------

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies:
1515
- fonttools>=4.22.0
1616
- importlib-resources>=3.2.0
1717
- kiwisolver>=1.0.1
18-
- numpy>=1.19
18+
- numpy>=1.20
1919
- pillow>=6.2
2020
- pybind11>=2.6.0
2121
- pygobject

examples/color/named_colors.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
on some common color categories.
1818
"""
1919

20+
import math
21+
2022
from matplotlib.patches import Rectangle
2123
import matplotlib.pyplot as plt
2224
import matplotlib.colors as mcolors
2325

2426

25-
def plot_colortable(colors, sort_colors=True, emptycols=0):
27+
def plot_colortable(colors, *, ncols=4, sort_colors=True):
2628

2729
cell_width = 212
2830
cell_height = 22
@@ -31,16 +33,13 @@ def plot_colortable(colors, sort_colors=True, emptycols=0):
3133

3234
# Sort colors by hue, saturation, value and name.
3335
if sort_colors is True:
34-
by_hsv = sorted((tuple(mcolors.rgb_to_hsv(mcolors.to_rgb(color))),
35-
name)
36-
for name, color in colors.items())
37-
names = [name for hsv, name in by_hsv]
36+
names = sorted(
37+
colors, key=lambda c: tuple(mcolors.rgb_to_hsv(mcolors.to_rgb(c))))
3838
else:
3939
names = list(colors)
4040

4141
n = len(names)
42-
ncols = 4 - emptycols
43-
nrows = n // ncols + int(n % ncols > 0)
42+
nrows = math.ceil(n / ncols)
4443

4544
width = cell_width * 4 + 2 * margin
4645
height = cell_height * nrows + 2 * margin
@@ -79,14 +78,14 @@ def plot_colortable(colors, sort_colors=True, emptycols=0):
7978
# Base colors
8079
# -----------
8180

82-
plot_colortable(mcolors.BASE_COLORS, sort_colors=False, emptycols=1)
81+
plot_colortable(mcolors.BASE_COLORS, ncols=3, sort_colors=False)
8382

8483
#############################################################################
8584
# ---------------
8685
# Tableau Palette
8786
# ---------------
8887

89-
plot_colortable(mcolors.TABLEAU_COLORS, sort_colors=False, emptycols=2)
88+
plot_colortable(mcolors.TABLEAU_COLORS, ncols=2, sort_colors=False)
9089

9190
#############################################################################
9291
# ----------
@@ -104,7 +103,7 @@ def plot_colortable(colors, sort_colors=True, emptycols=0):
104103
# XKCD colors are supported, but they produce a large figure, so we skip them
105104
# for now. You can use the following code if desired::
106105
#
107-
# xkcd_fig = plot_colortable(mcolors.XKCD_COLORS, "XKCD Colors")
106+
# xkcd_fig = plot_colortable(mcolors.XKCD_COLORS)
108107
# xkcd_fig.savefig("XKCD_Colors.png")
109108
#
110109
# .. admonition:: References

examples/lines_bars_and_markers/marker_reference.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ def split_list(a_list):
6060
ax.plot([y] * 3, marker=marker, **marker_style)
6161
format_axes(ax)
6262

63-
plt.show()
64-
65-
6663
###############################################################################
6764
# Filled markers
6865
# ==============
@@ -75,8 +72,6 @@ def split_list(a_list):
7572
ax.plot([y] * 3, marker=marker, **marker_style)
7673
format_axes(ax)
7774

78-
plt.show()
79-
8075
###############################################################################
8176
# .. _marker_fill_styles:
8277
#
@@ -102,9 +97,6 @@ def split_list(a_list):
10297
ax.plot([y] * 3, fillstyle=fill_style, **filled_marker_style)
10398
format_axes(ax)
10499

105-
plt.show()
106-
107-
108100
###############################################################################
109101
# Markers created from TeX symbols
110102
# ================================
@@ -128,9 +120,6 @@ def split_list(a_list):
128120
ax.plot([y] * 3, marker=marker, **marker_style)
129121
format_axes(ax)
130122

131-
plt.show()
132-
133-
134123
###############################################################################
135124
# Markers created from Paths
136125
# ==========================
@@ -160,8 +149,6 @@ def split_list(a_list):
160149
ax.plot([y] * 3, marker=marker, **marker_style)
161150
format_axes(ax)
162151

163-
plt.show()
164-
165152
###############################################################################
166153
# Advanced marker modifications with transform
167154
# ============================================
@@ -197,7 +184,6 @@ def split_list(a_list):
197184
format_axes(ax)
198185

199186
fig.tight_layout()
200-
plt.show()
201187

202188
###############################################################################
203189
# Setting marker cap style and join style
@@ -235,7 +221,6 @@ def split_list(a_list):
235221
ax.plot(x, y, marker=m, **marker_outer)
236222
ax.text(x, len(CapStyle) - .5, f'{theta}°', ha='center')
237223
format_axes(ax)
238-
plt.show()
239224

240225
###############################################################################
241226
# Modifying the join style:
Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,23 @@
11
"""
2-
========================================================================
3-
Shade regions defined by a logical mask using fill_between or span_where
4-
========================================================================
5-
6-
Shade regions where a logical mask is True with `.Axes.fill_between` or with
7-
`matplotlib.collections.BrokenBarHCollection.span_where`.
2+
==========================================================
3+
Shade regions defined by a logical mask using fill_between
4+
==========================================================
85
"""
96

107
import numpy as np
118
import matplotlib.pyplot as plt
12-
import matplotlib.collections as collections
139

1410

1511
t = np.arange(0.0, 2, 0.01)
1612
s = np.sin(2*np.pi*t)
1713

18-
fig, axs = plt.subplots(2, sharex=True, sharey=True)
19-
for ax in axs:
20-
ax.plot(t, s, color='black')
21-
ax.axhline(0, color='black')
14+
fig, ax = plt.subplots()
2215

23-
axs[0].set_title('using fill_between')
24-
axs[0].fill_between(t, 1, where=s > 0, facecolor='green', alpha=.5)
25-
axs[0].fill_between(t, -1, where=s < 0, facecolor='red', alpha=.5)
16+
ax.plot(t, s, color='black')
17+
ax.axhline(0, color='black')
2618

27-
axs[1].set_title('using span_where')
28-
axs[1].add_collection(collections.BrokenBarHCollection.span_where(
29-
t, ymin=0, ymax=1, where=s > 0, facecolor='green', alpha=0.5))
30-
axs[1].add_collection(collections.BrokenBarHCollection.span_where(
31-
t, ymin=-1, ymax=0, where=s < 0, facecolor='red', alpha=0.5))
19+
ax.fill_between(t, 1, where=s > 0, facecolor='green', alpha=.5)
20+
ax.fill_between(t, -1, where=s < 0, facecolor='red', alpha=.5)
3221

3322
plt.show()
3423

@@ -41,6 +30,3 @@
4130
# in this example:
4231
#
4332
# - `matplotlib.axes.Axes.fill_between`
44-
# - `matplotlib.collections.BrokenBarHCollection`
45-
# - `matplotlib.collections.BrokenBarHCollection.span_where`
46-
# - `matplotlib.axes.Axes.add_collection`

tutorials/provisional/mosaic.py renamed to examples/subplots_axes_and_figures/mosaic.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
"""
2-
=======================================
3-
Complex and semantic figure composition
4-
=======================================
2+
.. redirect-from:: /tutorials/provisional/mosaic
53
6-
.. warning::
74
8-
This tutorial documents experimental / provisional API.
9-
We are releasing this in v3.3 to get user feedback. We may
10-
make breaking changes in future versions with no warning.
115
6+
========================================================
7+
Complex and semantic figure composition (subplot_mosaic)
8+
========================================================
129
1310
Laying out Axes in a Figure in a non-uniform grid can be both tedious
1411
and verbose. For dense, even grids we have `.Figure.subplots` but for

examples/text_labels_and_annotations/figlegend_demo.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,26 @@
2828

2929
plt.tight_layout()
3030
plt.show()
31+
32+
##############################################################################
33+
# Sometimes we do not want the legend to overlap the axes. If you use
34+
# constrained_layout you can specify "outside right upper", and
35+
# constrained_layout will make room for the legend.
36+
37+
fig, axs = plt.subplots(1, 2, layout='constrained')
38+
39+
x = np.arange(0.0, 2.0, 0.02)
40+
y1 = np.sin(2 * np.pi * x)
41+
y2 = np.exp(-x)
42+
l1, = axs[0].plot(x, y1)
43+
l2, = axs[0].plot(x, y2, marker='o')
44+
45+
y3 = np.sin(4 * np.pi * x)
46+
y4 = np.exp(-2 * x)
47+
l3, = axs[1].plot(x, y3, color='tab:green')
48+
l4, = axs[1].plot(x, y4, color='tab:red', marker='^')
49+
50+
fig.legend((l1, l2), ('Line 1', 'Line 2'), loc='upper left')
51+
fig.legend((l3, l4), ('Line 3', 'Line 4'), loc='outside right upper')
52+
53+
plt.show()

lib/matplotlib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def _check_versions():
217217
("cycler", "0.10"),
218218
("dateutil", "2.7"),
219219
("kiwisolver", "1.0.1"),
220-
("numpy", "1.19"),
220+
("numpy", "1.20"),
221221
("pyparsing", "2.3.1"),
222222
]:
223223
module = importlib.import_module(modname)

0 commit comments

Comments
 (0)