Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ad8140b

Browse filesBrowse files
committed
Fix __qualname__ for Axes methods that are defined elsewhere
1 parent 1c4c9af commit ad8140b
Copy full SHA for ad8140b

File tree

Expand file treeCollapse file tree

1 file changed

+26
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+26
-7
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+26-7Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@
4343
# All the other methods should go in the _AxesBase class.
4444

4545

46+
def _make_axes_method(func):
47+
"""
48+
Patch the qualname for functions that are directly added to Axes.
49+
50+
Some Axes functionality is defined in functions in other submodules.
51+
These are simply added as attributes to Axes. As a result, their
52+
``__qualname__`` is e.g. only "table" and not "Axes.table". This
53+
function fixes that.
54+
55+
Note that the function itself is patched, so that
56+
``matplotlib.table.table.__qualname__` will also show "Axes.table".
57+
However, since these functions are not intended to be standalone,
58+
this is bearable.
59+
"""
60+
func.__qualname__ = f"Axes.{func.__name__}"
61+
return func
62+
63+
4664
@_docstring.interpd
4765
class Axes(_AxesBase):
4866
"""
@@ -8541,18 +8559,19 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5,
85418559

85428560
# Methods that are entirely implemented in other modules.
85438561

8544-
table = mtable.table
8562+
table = _make_axes_method(mtable.table)
85458563

85468564
# args can be either Y or y1, y2, ... and all should be replaced
8547-
stackplot = _preprocess_data()(mstack.stackplot)
8565+
stackplot = _preprocess_data()(_make_axes_method(mstack.stackplot))
85488566

85498567
streamplot = _preprocess_data(
8550-
replace_names=["x", "y", "u", "v", "start_points"])(mstream.streamplot)
8568+
replace_names=["x", "y", "u", "v", "start_points"])(
8569+
_make_axes_method(mstream.streamplot))
85518570

8552-
tricontour = mtri.tricontour
8553-
tricontourf = mtri.tricontourf
8554-
tripcolor = mtri.tripcolor
8555-
triplot = mtri.triplot
8571+
tricontour = _make_axes_method(mtri.tricontour)
8572+
tricontourf = _make_axes_method(mtri.tricontourf)
8573+
tripcolor = _make_axes_method(mtri.tripcolor)
8574+
triplot = _make_axes_method(mtri.triplot)
85568575

85578576
def _get_aspect_ratio(self):
85588577
"""

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.