aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-contrib <robot-contrib@yandex-team.com>2023-12-09 08:28:54 +0300
committerrobot-contrib <robot-contrib@yandex-team.com>2023-12-09 08:46:50 +0300
commitf82bfd2a08a51c4815a4cde64974f819ed4f7128 (patch)
treec32e089b8c5795342a1d4f4db2a942f4d326fc9c
parent1a5ddc956c05a593cbe2d043d5f4e190602d9b98 (diff)
downloadydb-f82bfd2a08a51c4815a4cde64974f819ed4f7128.tar.gz
Update contrib/python/matplotlib/py3 to 3.8.2
-rw-r--r--contrib/python/matplotlib/py3/.dist-info/METADATA6
-rw-r--r--contrib/python/matplotlib/py3/matplotlib/__init__.py2
-rw-r--r--contrib/python/matplotlib/py3/matplotlib/_version.py16
-rw-r--r--contrib/python/matplotlib/py3/matplotlib/axes/_axes.py13
-rw-r--r--contrib/python/matplotlib/py3/matplotlib/backend_bases.py6
-rw-r--r--contrib/python/matplotlib/py3/matplotlib/backends/backend_macosx.py77
-rw-r--r--contrib/python/matplotlib/py3/matplotlib/backends/backend_ps.py6
-rw-r--r--contrib/python/matplotlib/py3/matplotlib/cbook.py4
-rw-r--r--contrib/python/matplotlib/py3/matplotlib/cm.py5
-rw-r--r--contrib/python/matplotlib/py3/matplotlib/colorbar.py2
-rw-r--r--contrib/python/matplotlib/py3/matplotlib/colors.py6
-rw-r--r--contrib/python/matplotlib/py3/matplotlib/container.py2
-rw-r--r--contrib/python/matplotlib/py3/matplotlib/contour.py118
-rw-r--r--contrib/python/matplotlib/py3/matplotlib/figure.py42
-rw-r--r--contrib/python/matplotlib/py3/matplotlib/mpl-data/matplotlibrc2
-rw-r--r--contrib/python/matplotlib/py3/matplotlib/mpl-data/stylelib/classic.mplstyle2
-rw-r--r--contrib/python/matplotlib/py3/matplotlib/projections/__init__.py16
-rw-r--r--contrib/python/matplotlib/py3/matplotlib/pyplot.py33
-rw-r--r--contrib/python/matplotlib/py3/matplotlib/textpath.py2
-rw-r--r--contrib/python/matplotlib/py3/matplotlib/ticker.py22
-rw-r--r--contrib/python/matplotlib/py3/mpl_toolkits/mplot3d/axes3d.py2
-rw-r--r--contrib/python/matplotlib/py3/ya.make2
22 files changed, 213 insertions, 173 deletions
diff --git a/contrib/python/matplotlib/py3/.dist-info/METADATA b/contrib/python/matplotlib/py3/.dist-info/METADATA
index 9ac0481651..cdd2df573f 100644
--- a/contrib/python/matplotlib/py3/.dist-info/METADATA
+++ b/contrib/python/matplotlib/py3/.dist-info/METADATA
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: matplotlib
-Version: 3.8.0
+Version: 3.8.2
Summary: Python plotting package
Home-page: https://matplotlib.org
Download-URL: https://matplotlib.org/stable/users/installing/index.html
@@ -42,10 +42,10 @@ License-File: LICENSE/LICENSE_YORICK
Requires-Dist: contourpy >=1.0.1
Requires-Dist: cycler >=0.10
Requires-Dist: fonttools >=4.22.0
-Requires-Dist: kiwisolver >=1.0.1
+Requires-Dist: kiwisolver >=1.3.1
Requires-Dist: numpy <2,>=1.21
Requires-Dist: packaging >=20.0
-Requires-Dist: pillow >=6.2.0
+Requires-Dist: pillow >=8
Requires-Dist: pyparsing >=2.3.1
Requires-Dist: python-dateutil >=2.7
Requires-Dist: importlib-resources >=3.2.0 ; python_version<"3.10"
diff --git a/contrib/python/matplotlib/py3/matplotlib/__init__.py b/contrib/python/matplotlib/py3/matplotlib/__init__.py
index 86c9cdb592..6023b86b2a 100644
--- a/contrib/python/matplotlib/py3/matplotlib/__init__.py
+++ b/contrib/python/matplotlib/py3/matplotlib/__init__.py
@@ -246,7 +246,7 @@ def _check_versions():
for modname, minver in [
("cycler", "0.10"),
("dateutil", "2.7"),
- ("kiwisolver", "1.0.1"),
+ ("kiwisolver", "1.3.1"),
("numpy", "1.21"),
("pyparsing", "2.3.1"),
]:
diff --git a/contrib/python/matplotlib/py3/matplotlib/_version.py b/contrib/python/matplotlib/py3/matplotlib/_version.py
index 98c72b5d03..f14d882a3d 100644
--- a/contrib/python/matplotlib/py3/matplotlib/_version.py
+++ b/contrib/python/matplotlib/py3/matplotlib/_version.py
@@ -1,4 +1,16 @@
# file generated by setuptools_scm
# don't change, don't track in version control
-__version__ = version = '3.8.0'
-__version_tuple__ = version_tuple = (3, 8, 0)
+TYPE_CHECKING = False
+if TYPE_CHECKING:
+ from typing import Tuple, Union
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
+else:
+ VERSION_TUPLE = object
+
+version: str
+__version__: str
+__version_tuple__: VERSION_TUPLE
+version_tuple: VERSION_TUPLE
+
+__version__ = version = '3.8.2'
+__version_tuple__ = version_tuple = (3, 8, 2)
diff --git a/contrib/python/matplotlib/py3/matplotlib/axes/_axes.py b/contrib/python/matplotlib/py3/matplotlib/axes/_axes.py
index 2b1f1bddfc..b4a41099be 100644
--- a/contrib/python/matplotlib/py3/matplotlib/axes/_axes.py
+++ b/contrib/python/matplotlib/py3/matplotlib/axes/_axes.py
@@ -3382,7 +3382,7 @@ class Axes(_AxesBase):
Plot y versus x as lines and/or markers with attached errorbars.
*x*, *y* define the data locations, *xerr*, *yerr* define the errorbar
- sizes. By default, this draws the data markers/lines as well the
+ sizes. By default, this draws the data markers/lines as well as the
errorbars. Use fmt='none' to draw errorbars without any data markers.
.. versionadded:: 3.7
@@ -4858,8 +4858,8 @@ default: :rc:`scatter.edgecolors`
yscale : {'linear', 'log'}, default: 'linear'
Use a linear or log10 scale on the vertical axis.
- mincnt : int > 0, default: *None*
- If not *None*, only display cells with more than *mincnt*
+ mincnt : int >= 0, default: *None*
+ If not *None*, only display cells with at least *mincnt*
number of points in the cell.
marginals : bool, default: *False*
@@ -4926,6 +4926,11 @@ default: :rc:`scatter.edgecolors`
- `numpy.sum`: integral of the point values
- `numpy.amax`: value taken from the largest point
+ By default will only reduce cells with at least 1 point because some
+ reduction functions (such as `numpy.amax`) will error/warn with empty
+ input. Changing *mincnt* will adjust the cutoff, and if set to 0 will
+ pass empty input to the reduction function.
+
data : indexable object, optional
DATA_PARAMETER_PLACEHOLDER
@@ -5023,7 +5028,7 @@ default: :rc:`scatter.edgecolors`
else:
Cs_at_i2[i2[i]].append(C[i])
if mincnt is None:
- mincnt = 0
+ mincnt = 1
accum = np.array(
[reduce_C_function(acc) if len(acc) >= mincnt else np.nan
for Cs_at_i in [Cs_at_i1, Cs_at_i2]
diff --git a/contrib/python/matplotlib/py3/matplotlib/backend_bases.py b/contrib/python/matplotlib/py3/matplotlib/backend_bases.py
index 9c7fa97d23..958b6e0e1c 100644
--- a/contrib/python/matplotlib/py3/matplotlib/backend_bases.py
+++ b/contrib/python/matplotlib/py3/matplotlib/backend_bases.py
@@ -2123,6 +2123,12 @@ class FigureCanvasBase:
if dpi == 'figure':
dpi = getattr(self.figure, '_original_dpi', self.figure.dpi)
+ if kwargs.get("papertype") == 'auto':
+ # When deprecation elapses, remove backend_ps._get_papertype & its callers.
+ _api.warn_deprecated(
+ "3.8", name="papertype='auto'", addendum="Pass an explicit paper type, "
+ "'figure', or omit the *papertype* argument entirely.")
+
# Remove the figure manager, if any, to avoid resizing the GUI widget.
with cbook._setattr_cm(self, manager=None), \
self._switch_canvas_and_return_print_method(format, backend) \
diff --git a/contrib/python/matplotlib/py3/matplotlib/backends/backend_macosx.py b/contrib/python/matplotlib/py3/matplotlib/backends/backend_macosx.py
index 1d92ec602d..a39f5b5b14 100644
--- a/contrib/python/matplotlib/py3/matplotlib/backends/backend_macosx.py
+++ b/contrib/python/matplotlib/py3/matplotlib/backends/backend_macosx.py
@@ -1,3 +1,4 @@
+import contextlib
import os
import signal
import socket
@@ -106,6 +107,13 @@ class FigureCanvasMac(FigureCanvasAgg, _macosx.FigureCanvas, FigureCanvasBase):
ResizeEvent("resize_event", self)._process()
self.draw_idle()
+ def start_event_loop(self, timeout=0):
+ # docstring inherited
+ with _maybe_allow_interrupt():
+ # Call the objc implementation of the event loop after
+ # setting up the interrupt handling
+ self._start_event_loop(timeout=timeout)
+
class NavigationToolbar2Mac(_macosx.NavigationToolbar2, NavigationToolbar2):
@@ -147,7 +155,7 @@ class FigureManagerMac(_macosx.FigureManager, FigureManagerBase):
icon_path = str(cbook._get_data_path('images/matplotlib.pdf'))
_macosx.FigureManager.set_icon(icon_path)
FigureManagerBase.__init__(self, canvas, num)
- self._set_window_mode(mpl.rcParams.get("macosx.window_mode", "system"))
+ self._set_window_mode(mpl.rcParams["macosx.window_mode"])
if self.toolbar is not None:
self.toolbar.update()
if mpl.is_interactive():
@@ -171,34 +179,8 @@ class FigureManagerMac(_macosx.FigureManager, FigureManagerBase):
# Set up a SIGINT handler to allow terminating a plot via CTRL-C.
# The logic is largely copied from qt_compat._maybe_allow_interrupt; see its
# docstring for details. Parts are implemented by wake_on_fd_write in ObjC.
-
- old_sigint_handler = signal.getsignal(signal.SIGINT)
- if old_sigint_handler in (None, signal.SIG_IGN, signal.SIG_DFL):
- _macosx.show()
- return
-
- handler_args = None
- wsock, rsock = socket.socketpair()
- wsock.setblocking(False)
- rsock.setblocking(False)
- old_wakeup_fd = signal.set_wakeup_fd(wsock.fileno())
- _macosx.wake_on_fd_write(rsock.fileno())
-
- def handle(*args):
- nonlocal handler_args
- handler_args = args
- _macosx.stop()
-
- signal.signal(signal.SIGINT, handle)
- try:
+ with _maybe_allow_interrupt():
_macosx.show()
- finally:
- wsock.close()
- rsock.close()
- signal.set_wakeup_fd(old_wakeup_fd)
- signal.signal(signal.SIGINT, old_sigint_handler)
- if handler_args is not None:
- old_sigint_handler(*handler_args)
def show(self):
if not self._shown:
@@ -208,6 +190,45 @@ class FigureManagerMac(_macosx.FigureManager, FigureManagerBase):
self._raise()
+@contextlib.contextmanager
+def _maybe_allow_interrupt():
+ """
+ This manager allows to terminate a plot by sending a SIGINT. It is
+ necessary because the running backend prevents Python interpreter to
+ run and process signals (i.e., to raise KeyboardInterrupt exception). To
+ solve this one needs to somehow wake up the interpreter and make it close
+ the plot window. The implementation is taken from qt_compat, see that
+ docstring for a more detailed description.
+ """
+ old_sigint_handler = signal.getsignal(signal.SIGINT)
+ if old_sigint_handler in (None, signal.SIG_IGN, signal.SIG_DFL):
+ yield
+ return
+
+ handler_args = None
+ wsock, rsock = socket.socketpair()
+ wsock.setblocking(False)
+ rsock.setblocking(False)
+ old_wakeup_fd = signal.set_wakeup_fd(wsock.fileno())
+ _macosx.wake_on_fd_write(rsock.fileno())
+
+ def handle(*args):
+ nonlocal handler_args
+ handler_args = args
+ _macosx.stop()
+
+ signal.signal(signal.SIGINT, handle)
+ try:
+ yield
+ finally:
+ wsock.close()
+ rsock.close()
+ signal.set_wakeup_fd(old_wakeup_fd)
+ signal.signal(signal.SIGINT, old_sigint_handler)
+ if handler_args is not None:
+ old_sigint_handler(*handler_args)
+
+
@_Backend.export
class _BackendMac(_Backend):
FigureCanvas = FigureCanvasMac
diff --git a/contrib/python/matplotlib/py3/matplotlib/backends/backend_ps.py b/contrib/python/matplotlib/py3/matplotlib/backends/backend_ps.py
index a757bcf8d3..2f9faa0ef6 100644
--- a/contrib/python/matplotlib/py3/matplotlib/backends/backend_ps.py
+++ b/contrib/python/matplotlib/py3/matplotlib/backends/backend_ps.py
@@ -872,9 +872,6 @@ class FigureCanvasPS(FigureCanvasBase):
# find the appropriate papertype
width, height = self.figure.get_size_inches()
if papertype == 'auto':
- _api.warn_deprecated("3.8", name="papertype='auto'",
- addendum="Pass an explicit paper type, 'figure', or "
- "omit the *papertype* argument entirely.")
papertype = _get_papertype(*orientation.swap_if_landscape((width, height)))
if is_eps or papertype == 'figure':
@@ -1058,9 +1055,6 @@ showpage
self.figure.get_size_inches())
else:
if papertype == 'auto':
- _api.warn_deprecated("3.8", name="papertype='auto'",
- addendum="Pass an explicit paper type, or "
- "omit the *papertype* argument entirely.")
papertype = _get_papertype(width, height)
paper_width, paper_height = papersize[papertype]
diff --git a/contrib/python/matplotlib/py3/matplotlib/cbook.py b/contrib/python/matplotlib/py3/matplotlib/cbook.py
index 80ec161268..f02486a0e2 100644
--- a/contrib/python/matplotlib/py3/matplotlib/cbook.py
+++ b/contrib/python/matplotlib/py3/matplotlib/cbook.py
@@ -1685,7 +1685,7 @@ def safe_first_element(obj):
def _safe_first_finite(obj, *, skip_nonfinite=True):
"""
Return the first finite element in *obj* if one is available and skip_nonfinite is
- True. Otherwise return the first element.
+ True. Otherwise, return the first element.
This is a method for internal use.
@@ -1697,7 +1697,7 @@ def _safe_first_finite(obj, *, skip_nonfinite=True):
return False
try:
return math.isfinite(val)
- except TypeError:
+ except (TypeError, ValueError):
pass
try:
return np.isfinite(val) if np.isscalar(val) else True
diff --git a/contrib/python/matplotlib/py3/matplotlib/cm.py b/contrib/python/matplotlib/py3/matplotlib/cm.py
index a2cd378811..3911986f36 100644
--- a/contrib/python/matplotlib/py3/matplotlib/cm.py
+++ b/contrib/python/matplotlib/py3/matplotlib/cm.py
@@ -74,6 +74,11 @@ class ColormapRegistry(Mapping):
Additional colormaps can be added via `.ColormapRegistry.register`::
mpl.colormaps.register(my_colormap)
+
+ To get a list of all registered colormaps, you can do::
+
+ from matplotlib import colormaps
+ list(colormaps)
"""
def __init__(self, cmaps):
self._cmaps = cmaps
diff --git a/contrib/python/matplotlib/py3/matplotlib/colorbar.py b/contrib/python/matplotlib/py3/matplotlib/colorbar.py
index 5c37eef519..6c92f37953 100644
--- a/contrib/python/matplotlib/py3/matplotlib/colorbar.py
+++ b/contrib/python/matplotlib/py3/matplotlib/colorbar.py
@@ -404,7 +404,7 @@ class Colorbar:
try:
self._formatter = ticker.FormatStrFormatter(format)
_ = self._formatter(0)
- except TypeError:
+ except (TypeError, ValueError):
self._formatter = ticker.StrMethodFormatter(format)
else:
self._formatter = format # Assume it is a Formatter or None
diff --git a/contrib/python/matplotlib/py3/matplotlib/colors.py b/contrib/python/matplotlib/py3/matplotlib/colors.py
index 904b6ecfa0..bd89e70049 100644
--- a/contrib/python/matplotlib/py3/matplotlib/colors.py
+++ b/contrib/python/matplotlib/py3/matplotlib/colors.py
@@ -435,7 +435,7 @@ def to_rgba_array(c, alpha=None):
(n, 4) array of RGBA colors, where each channel (red, green, blue,
alpha) can assume values between 0 and 1.
"""
- if isinstance(c, tuple) and len(c) == 2:
+ if isinstance(c, tuple) and len(c) == 2 and isinstance(c[1], Real):
if alpha is None:
c, alpha = c
else:
@@ -2725,8 +2725,8 @@ def from_levels_and_colors(levels, colors, extend='neither'):
Returns
-------
- cmap : `~matplotlib.colors.Normalize`
- norm : `~matplotlib.colors.Colormap`
+ cmap : `~matplotlib.colors.Colormap`
+ norm : `~matplotlib.colors.Normalize`
"""
slice_map = {
'both': slice(1, -1),
diff --git a/contrib/python/matplotlib/py3/matplotlib/container.py b/contrib/python/matplotlib/py3/matplotlib/container.py
index e11fea3918..0f082e298a 100644
--- a/contrib/python/matplotlib/py3/matplotlib/container.py
+++ b/contrib/python/matplotlib/py3/matplotlib/container.py
@@ -19,7 +19,7 @@ class Container(tuple):
def __init__(self, kl, label=None):
self._callbacks = cbook.CallbackRegistry(signals=["pchanged"])
self._remove_method = None
- self._label = label
+ self._label = str(label) if label is not None else None
def remove(self):
for c in cbook.flatten(
diff --git a/contrib/python/matplotlib/py3/matplotlib/contour.py b/contrib/python/matplotlib/py3/matplotlib/contour.py
index efea024dc1..6e88996864 100644
--- a/contrib/python/matplotlib/py3/matplotlib/contour.py
+++ b/contrib/python/matplotlib/py3/matplotlib/contour.py
@@ -2,6 +2,7 @@
Classes to support contour plotting and labelling for the Axes class.
"""
+from contextlib import ExitStack
import functools
import math
from numbers import Integral
@@ -350,6 +351,11 @@ class ContourLabeler:
taken into account when breaking the path, but not when computing the angle.
"""
if hasattr(self, "_old_style_split_collections"):
+ vis = False
+ for coll in self._old_style_split_collections:
+ vis |= coll.get_visible()
+ coll.remove()
+ self.set_visible(vis)
del self._old_style_split_collections # Invalidate them.
xys = path.vertices
@@ -383,7 +389,7 @@ class ContourLabeler:
# If the path is closed, rotate it s.t. it starts at the label.
is_closed_path = codes[stop - 1] == Path.CLOSEPOLY
if is_closed_path:
- cc_xys = np.concatenate([xys[idx:-1], xys[:idx+1]])
+ cc_xys = np.concatenate([cc_xys[idx:-1], cc_xys[:idx+1]])
idx = 0
# Like np.interp, but additionally vectorized over fp.
@@ -418,8 +424,13 @@ class ContourLabeler:
new_code_blocks = []
if is_closed_path:
if i0 != -1 and i1 != -1:
- new_xy_blocks.extend([[(x1, y1)], cc_xys[i1:i0+1], [(x0, y0)]])
- new_code_blocks.extend([[Path.MOVETO], [Path.LINETO] * (i0 + 2 - i1)])
+ # This is probably wrong in the case that the entire contour would
+ # be discarded, but ensures that a valid path is returned and is
+ # consistent with behavior of mpl <3.8
+ points = cc_xys[i1:i0+1]
+ new_xy_blocks.extend([[(x1, y1)], points, [(x0, y0)]])
+ nlines = len(points) + 1
+ new_code_blocks.extend([[Path.MOVETO], [Path.LINETO] * nlines])
else:
if i0 != -1:
new_xy_blocks.extend([cc_xys[:i0 + 1], [(x0, y0)]])
@@ -934,10 +945,12 @@ class ContourSet(ContourLabeler, mcoll.Collection):
", ".join(map(repr, kwargs))
)
- allsegs = _api.deprecated("3.8", pending=True)(property(lambda self: [
- p.vertices for c in self.collections for p in c.get_paths()]))
- allkinds = _api.deprecated("3.8", pending=True)(property(lambda self: [
- p.codes for c in self.collections for p in c.get_paths()]))
+ allsegs = property(lambda self: [
+ [subp.vertices for subp in p._iter_connected_components()]
+ for p in self.get_paths()])
+ allkinds = property(lambda self: [
+ [subp.codes for subp in p._iter_connected_components()]
+ for p in self.get_paths()])
tcolors = _api.deprecated("3.8")(property(lambda self: [
(tuple(rgba),) for rgba in self.to_rgba(self.cvalues, self.alpha)]))
tlinewidths = _api.deprecated("3.8")(property(lambda self: [
@@ -1379,19 +1392,21 @@ class ContourSet(ContourLabeler, mcoll.Collection):
for idx_level in indices:
path = self._paths[idx_level]
- if not len(path.vertices):
- continue
- lc = self.get_transform().transform(path.vertices)
- d2, proj, leg = _find_closest_point_on_path(lc, xy)
- if d2 < d2min:
- d2min = d2
- idx_level_min = idx_level
- idx_vtx_min = leg[1]
- proj_min = proj
+ idx_vtx_start = 0
+ for subpath in path._iter_connected_components():
+ if not len(subpath.vertices):
+ continue
+ lc = self.get_transform().transform(subpath.vertices)
+ d2, proj, leg = _find_closest_point_on_path(lc, xy)
+ if d2 < d2min:
+ d2min = d2
+ idx_level_min = idx_level
+ idx_vtx_min = leg[1] + idx_vtx_start
+ proj_min = proj
+ idx_vtx_start += len(subpath)
return idx_level_min, idx_vtx_min, proj_min
- @_api.deprecated("3.8")
def find_nearest_contour(self, x, y, indices=None, pixel=True):
"""
Find the point in the contour plot that is closest to ``(x, y)``.
@@ -1412,64 +1427,39 @@ class ContourSet(ContourLabeler, mcoll.Collection):
Returns
-------
- contour : `.Collection`
- The contour that is closest to ``(x, y)``.
- segment : int
- The index of the `.Path` in *contour* that is closest to
- ``(x, y)``.
+ path : int
+ The index of the path that is closest to ``(x, y)``. Each path corresponds
+ to one contour level.
+ subpath : int
+ The index within that closest path of the subpath that is closest to
+ ``(x, y)``. Each subpath corresponds to one unbroken contour line.
index : int
- The index of the path segment in *segment* that is closest to
+ The index of the vertices within that subpath that are closest to
``(x, y)``.
xmin, ymin : float
The point in the contour plot that is closest to ``(x, y)``.
d2 : float
The squared distance from ``(xmin, ymin)`` to ``(x, y)``.
"""
+ segment = index = d2 = None
- # This function uses a method that is probably quite
- # inefficient based on converting each contour segment to
- # pixel coordinates and then comparing the given point to
- # those coordinates for each contour. This will probably be
- # quite slow for complex contours, but for normal use it works
- # sufficiently well that the time is not noticeable.
- # Nonetheless, improvements could probably be made.
-
- if self.filled:
- raise ValueError("Method does not support filled contours.")
+ with ExitStack() as stack:
+ if not pixel:
+ # _find_nearest_contour works in pixel space. We want axes space, so
+ # effectively disable the transformation here by setting to identity.
+ stack.enter_context(self._cm_set(
+ transform=mtransforms.IdentityTransform()))
- if indices is None:
- indices = range(len(self.collections))
+ i_level, i_vtx, (xmin, ymin) = self._find_nearest_contour((x, y), indices)
- d2min = np.inf
- conmin = None
- segmin = None
- imin = None
- xmin = None
- ymin = None
-
- point = np.array([x, y])
-
- for icon in indices:
- con = self.collections[icon]
- trans = con.get_transform()
- paths = con.get_paths()
-
- for segNum, linepath in enumerate(paths):
- lc = linepath.vertices
- # transfer all data points to screen coordinates if desired
- if pixel:
- lc = trans.transform(lc)
-
- d2, xc, leg = _find_closest_point_on_path(lc, point)
- if d2 < d2min:
- d2min = d2
- conmin = icon
- segmin = segNum
- imin = leg[1]
- xmin = xc[0]
- ymin = xc[1]
+ if i_level is not None:
+ cc_cumlens = np.cumsum(
+ [*map(len, self._paths[i_level]._iter_connected_components())])
+ segment = cc_cumlens.searchsorted(i_vtx, "right")
+ index = i_vtx if segment == 0 else i_vtx - cc_cumlens[segment - 1]
+ d2 = (xmin-x)**2 + (ymin-y)**2
- return (conmin, segmin, imin, xmin, ymin, d2min)
+ return (i_level, segment, index, xmin, ymin, d2)
def draw(self, renderer):
paths = self._paths
diff --git a/contrib/python/matplotlib/py3/matplotlib/figure.py b/contrib/python/matplotlib/py3/matplotlib/figure.py
index 9a75811fe1..e8a5f154d5 100644
--- a/contrib/python/matplotlib/py3/matplotlib/figure.py
+++ b/contrib/python/matplotlib/py3/matplotlib/figure.py
@@ -27,7 +27,7 @@ Figures are typically created using pyplot methods `~.pyplot.figure`,
Some situations call for directly instantiating a `~.figure.Figure` class,
usually inside an application of some sort (see :ref:`user_interfaces` for a
list of examples) . More information about Figures can be found at
-:ref:`figure_explanation`.
+:ref:`figure-intro`.
"""
from contextlib import ExitStack
@@ -3237,10 +3237,10 @@ None}, default: None
Call signature::
- savefig(fname, *, dpi='figure', format=None, metadata=None,
- bbox_inches=None, pad_inches=0.1,
- facecolor='auto', edgecolor='auto',
- backend=None, **kwargs
+ savefig(fname, *, transparent=None, dpi='figure', format=None,
+ metadata=None, bbox_inches=None, pad_inches=0.1,
+ facecolor='auto', edgecolor='auto', backend=None,
+ **kwargs
)
The available output formats depend on the backend being used.
@@ -3265,6 +3265,22 @@ None}, default: None
Other Parameters
----------------
+ transparent : bool, default: :rc:`savefig.transparent`
+ If *True*, the Axes patches will all be transparent; the
+ Figure patch will also be transparent unless *facecolor*
+ and/or *edgecolor* are specified via kwargs.
+
+ If *False* has no effect and the color of the Axes and
+ Figure patches are unchanged (unless the Figure patch
+ is specified via the *facecolor* and/or *edgecolor* keyword
+ arguments in which case those colors are used).
+
+ The transparency of these patches will be restored to their
+ original values upon exit of this function.
+
+ This is useful, for example, for displaying
+ a plot on top of a colored background on a web page.
+
dpi : float or 'figure', default: :rc:`savefig.dpi`
The resolution in dots per inch. If 'figure', use the figure's
dpi value.
@@ -3324,22 +3340,6 @@ None}, default: None
'a10', 'b0' through 'b10'. Only supported for postscript
output.
- transparent : bool
- If *True*, the Axes patches will all be transparent; the
- Figure patch will also be transparent unless *facecolor*
- and/or *edgecolor* are specified via kwargs.
-
- If *False* has no effect and the color of the Axes and
- Figure patches are unchanged (unless the Figure patch
- is specified via the *facecolor* and/or *edgecolor* keyword
- arguments in which case those colors are used).
-
- The transparency of these patches will be restored to their
- original values upon exit of this function.
-
- This is useful, for example, for displaying
- a plot on top of a colored background on a web page.
-
bbox_extra_artists : list of `~matplotlib.artist.Artist`, optional
A list of extra artists that will be considered when the
tight bbox is calculated.
diff --git a/contrib/python/matplotlib/py3/matplotlib/mpl-data/matplotlibrc b/contrib/python/matplotlib/py3/matplotlib/mpl-data/matplotlibrc
index 2c53651da3..5014aa4489 100644
--- a/contrib/python/matplotlib/py3/matplotlib/mpl-data/matplotlibrc
+++ b/contrib/python/matplotlib/py3/matplotlib/mpl-data/matplotlibrc
@@ -269,7 +269,7 @@
#font.serif: DejaVu Serif, Bitstream Vera Serif, Computer Modern Roman, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif
#font.sans-serif: DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
#font.cursive: Apple Chancery, Textile, Zapf Chancery, Sand, Script MT, Felipa, Comic Neue, Comic Sans MS, cursive
-#font.fantasy: Chicago, Charcoal, Impact, Western, Humor Sans, xkcd, fantasy
+#font.fantasy: Chicago, Charcoal, Impact, Western, xkcd script, fantasy
#font.monospace: DejaVu Sans Mono, Bitstream Vera Sans Mono, Computer Modern Typewriter, Andale Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace
diff --git a/contrib/python/matplotlib/py3/matplotlib/mpl-data/stylelib/classic.mplstyle b/contrib/python/matplotlib/py3/matplotlib/mpl-data/stylelib/classic.mplstyle
index 09a38df282..e1768e5a61 100644
--- a/contrib/python/matplotlib/py3/matplotlib/mpl-data/stylelib/classic.mplstyle
+++ b/contrib/python/matplotlib/py3/matplotlib/mpl-data/stylelib/classic.mplstyle
@@ -91,7 +91,7 @@ font.size : 12.0
font.serif : DejaVu Serif, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif
font.sans-serif: DejaVu Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
font.cursive : Apple Chancery, Textile, Zapf Chancery, Sand, Script MT, Felipa, cursive
-font.fantasy : Comic Sans MS, Chicago, Charcoal, ImpactWestern, Humor Sans, fantasy
+font.fantasy : Comic Sans MS, Chicago, Charcoal, ImpactWestern, xkcd script, fantasy
font.monospace : DejaVu Sans Mono, Andale Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace
### TEXT
diff --git a/contrib/python/matplotlib/py3/matplotlib/projections/__init__.py b/contrib/python/matplotlib/py3/matplotlib/projections/__init__.py
index 16a5651da1..4c5ef8e250 100644
--- a/contrib/python/matplotlib/py3/matplotlib/projections/__init__.py
+++ b/contrib/python/matplotlib/py3/matplotlib/projections/__init__.py
@@ -55,7 +55,15 @@ A full-fledged and heavily annotated example is in
from .. import axes, _docstring
from .geo import AitoffAxes, HammerAxes, LambertAxes, MollweideAxes
from .polar import PolarAxes
-from mpl_toolkits.mplot3d import Axes3D
+
+try:
+ from mpl_toolkits.mplot3d import Axes3D
+except Exception:
+ import warnings
+ warnings.warn("Unable to import Axes3D. This may be due to multiple versions of "
+ "Matplotlib being installed (e.g. as a system package and as a pip "
+ "package). As a result, the 3D projection is not available.")
+ Axes3D = None
class ProjectionRegistry:
@@ -87,8 +95,12 @@ projection_registry.register(
HammerAxes,
LambertAxes,
MollweideAxes,
- Axes3D,
)
+if Axes3D is not None:
+ projection_registry.register(Axes3D)
+else:
+ # remove from namespace if not importable
+ del Axes3D
def register_projection(cls):
diff --git a/contrib/python/matplotlib/py3/matplotlib/pyplot.py b/contrib/python/matplotlib/py3/matplotlib/pyplot.py
index 00e5dea071..62f7eba74e 100644
--- a/contrib/python/matplotlib/py3/matplotlib/pyplot.py
+++ b/contrib/python/matplotlib/py3/matplotlib/pyplot.py
@@ -479,7 +479,7 @@ def draw_if_interactive(*args, **kwargs):
# This function's signature is rewritten upon backend-load by switch_backend.
-def show(*args, **kwargs):
+def show(*args, **kwargs) -> None:
"""
Display all open figures.
@@ -707,11 +707,12 @@ def xkcd(
scale: float = 1, length: float = 100, randomness: float = 2
) -> ExitStack:
"""
- Turn on `xkcd <https://xkcd.com/>`_ sketch-style drawing mode. This will
- only have effect on things drawn after this function is called.
+ Turn on `xkcd <https://xkcd.com/>`_ sketch-style drawing mode.
- For best results, the "Humor Sans" font should be installed: it is
- not included with Matplotlib.
+ This will only have an effect on things drawn after this function is called.
+
+ For best results, install the `xkcd script <https://github.com/ipython/xkcd-font/>`_
+ font; xkcd fonts are not packaged with Matplotlib.
Parameters
----------
@@ -750,8 +751,7 @@ def xkcd(
from matplotlib import patheffects
rcParams.update({
- 'font.family': ['xkcd', 'xkcd Script', 'Humor Sans', 'Comic Neue',
- 'Comic Sans MS'],
+ 'font.family': ['xkcd', 'xkcd Script', 'Comic Neue', 'Comic Sans MS'],
'font.size': 14.0,
'path.sketch': (scale, length, randomness),
'path.effects': [
@@ -2413,18 +2413,15 @@ def matshow(A: ArrayLike, fignum: None | int = None, **kwargs) -> AxesImage:
The matrix to be displayed.
fignum : None or int
- If *None*, create a new figure window with automatic numbering.
-
- If a nonzero integer, draw into the figure with the given number
- (create it if it does not exist).
-
- If 0, use the current axes (or create one if it does not exist).
+ If *None*, create a new, appropriately sized figure window.
- .. note::
+ If 0, use the current Axes (creating one if there is none, without ever
+ adjusting the figure size).
- Because of how `.Axes.matshow` tries to set the figure aspect
- ratio to be the one of the array, strange things may happen if you
- reuse an existing figure.
+ Otherwise, create a new Axes on the figure with the given number
+ (creating it at the appropriate size if it does not exist, but not
+ adjusting the figure size otherwise). Note that this will be drawn on
+ top of any preexisting Axes on the figure.
Returns
-------
@@ -3670,7 +3667,7 @@ def scatter(
x: float | ArrayLike,
y: float | ArrayLike,
s: float | ArrayLike | None = None,
- c: Sequence[ColorType] | ColorType | None = None,
+ c: ArrayLike | Sequence[ColorType] | ColorType | None = None,
marker: MarkerType | None = None,
cmap: str | Colormap | None = None,
norm: str | Normalize | None = None,
diff --git a/contrib/python/matplotlib/py3/matplotlib/textpath.py b/contrib/python/matplotlib/py3/matplotlib/textpath.py
index de97899f8a..c00966d6e6 100644
--- a/contrib/python/matplotlib/py3/matplotlib/textpath.py
+++ b/contrib/python/matplotlib/py3/matplotlib/textpath.py
@@ -99,7 +99,7 @@ class TextToPath:
from matplotlib.text import TextToPath
from matplotlib.font_manager import FontProperties
- fp = FontProperties(family="Humor Sans", style="italic")
+ fp = FontProperties(family="Comic Neue", style="italic")
verts, codes = TextToPath().get_text_path(fp, "ABC")
path = Path(verts, codes, closed=False)
diff --git a/contrib/python/matplotlib/py3/matplotlib/ticker.py b/contrib/python/matplotlib/py3/matplotlib/ticker.py
index df848ef04a..5b1b7e1140 100644
--- a/contrib/python/matplotlib/py3/matplotlib/ticker.py
+++ b/contrib/python/matplotlib/py3/matplotlib/ticker.py
@@ -516,11 +516,11 @@ class ScalarFormatter(Formatter):
Format *arg* with *fmt*, applying Unicode minus and locale if desired.
"""
return self.fix_minus(
- # Escape commas introduced by format_string but not those present
- # from the beginning in fmt.
- ",".join(locale.format_string(part, (arg,), True)
- .replace(",", "{,}")
- for part in fmt.split(","))
+ # Escape commas introduced by locale.format_string if using math text,
+ # but not those present from the beginning in fmt.
+ (",".join(locale.format_string(part, (arg,), True).replace(",", "{,}")
+ for part in fmt.split(",")) if self._useMathText
+ else locale.format_string(fmt, (arg,), True))
if self._useLocale
else fmt % arg)
@@ -1996,13 +1996,11 @@ class MaxNLocator(Locator):
If True, autoscaling will result in a range symmetric about zero.
prune : {'lower', 'upper', 'both', None}, default: None
- Remove edge ticks -- useful for stacked or ganged plots where
- the upper tick of one axes overlaps with the lower tick of the
- axes above it, primarily when :rc:`axes.autolimit_mode` is
- ``'round_numbers'``. If ``prune=='lower'``, the smallest tick will
- be removed. If ``prune == 'upper'``, the largest tick will be
- removed. If ``prune == 'both'``, the largest and smallest ticks
- will be removed. If *prune* is *None*, no ticks will be removed.
+ Remove the 'lower' tick, the 'upper' tick, or ticks on 'both' sides
+ *if they fall exactly on an axis' edge* (this typically occurs when
+ :rc:`axes.autolimit_mode` is 'round_numbers'). Removing such ticks
+ is mostly useful for stacked or ganged plots, where the upper tick
+ of an axes overlaps with the lower tick of the axes above it.
min_n_ticks : int, default: 2
Relax *nbins* and *integer* constraints if necessary to obtain
diff --git a/contrib/python/matplotlib/py3/mpl_toolkits/mplot3d/axes3d.py b/contrib/python/matplotlib/py3/mpl_toolkits/mplot3d/axes3d.py
index aeb6a66d2c..a74c11f54e 100644
--- a/contrib/python/matplotlib/py3/mpl_toolkits/mplot3d/axes3d.py
+++ b/contrib/python/matplotlib/py3/mpl_toolkits/mplot3d/axes3d.py
@@ -2374,7 +2374,7 @@ class Axes3D(Axes):
xs, ys, zs, s, c, color = cbook.delete_masked_points(
xs, ys, zs, s, c, kwargs.get('color', None)
)
- if kwargs.get('color', None):
+ if kwargs.get("color") is not None:
kwargs['color'] = color
# For xs and ys, 2D scatter() will do the copying.
diff --git a/contrib/python/matplotlib/py3/ya.make b/contrib/python/matplotlib/py3/ya.make
index 44b928284c..5105631673 100644
--- a/contrib/python/matplotlib/py3/ya.make
+++ b/contrib/python/matplotlib/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(3.8.0)
+VERSION(3.8.2)
LICENSE(PSF-2.0)