Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Add type stubs for Axes3D and improve type hints in _AxesBase#30713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
ABarpanda wants to merge5 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromABarpanda:abarpanda
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletionlib/matplotlib/axes/_axes.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5066,7 +5066,7 @@ def invalid_shape_exception(csize, xsize):
"facecolors", "color"],
label_namer="y")
@_docstring.interpd
def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
def scatter(self, x, y,z=0,s=None, c=None, marker=None, cmap=None, norm=None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You can't change the signature of Axes methods. Please revert.

vmin=None, vmax=None, alpha=None, linewidths=None, *,
edgecolors=None, colorizer=None, plotnonfinite=False, **kwargs):
"""
Expand All@@ -5077,6 +5077,10 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
x, y : float or array-like, shape (n, )
The data positions.

zs : float or array-like, default: 0
The z-positions. Either an array of the same length as *xs* and
*ys* or a single value to place all points in the same plane.

s : float or array-like, shape (n, ), optional
The marker size in points**2 (typographic points are 1/72 in.).
Default is ``rcParams['lines.markersize'] ** 2``.
Expand Down
1 change: 1 addition & 0 deletionslib/matplotlib/axes/_axes.pyi
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -409,10 +409,11 @@
capwidths: float | ArrayLike | None = ...,
label: Sequence[str] | None = ...,
) -> dict[str, Any]: ...
def scatter(

Check failure on line 412 in lib/matplotlib/axes/_axes.pyi

View workflow job for this annotation

GitHub Actions/ mypy-stubtest

[mypy-stubtest] reported by reviewdog 🐶matplotlib.axes._axes.Axes.scatter is inconsistent, runtime parameter "z" has a default value but stub parameter does notdef (self: matplotlib.axes._axes.Axes, x: builtins.float | numpy._typing._array_like._Buffer | numpy._typing._array_like._SupportsArray[numpy.dtype[Any]] | numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]] | builtins.complex | builtins.bytes | builtins.str | numpy._typing._nested_sequence._NestedSequence[builtins.complex | builtins.bytes | builtins.str], y: builtins.float | numpy._typing._array_like._Buffer | numpy._typing._array_like._SupportsArray[numpy.dtype[Any]] | numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]] | builtins.complex | builtins.bytes | builtins.str | numpy._typing._nested_sequence._NestedSequence[builtins.complex | builtins.bytes | builtins.str], z: builtins.float | numpy._typing._array_like._Buffer | numpy._typing._array_like._SupportsArray[numpy.dtype[Any]] | numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]] | builtins.complex | builtins.bytes | builtins.str | numpy._typing._nested_sequence._NestedSequence[builtins.complex | builtins.bytes | builtins.str], s: builtins.float | numpy._typing._array_like._Buffer | numpy._typing._array_like._SupportsArray[numpy.dtype[Any]] | numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]] | builtins.complex | builtins.bytes | builtins.str | numpy._typing._nested_sequence._NestedSequence[builtins.complex | builtins.bytes | builtins.str] | None =, c: numpy._typing._array_like._Buffer | numpy._typing._array_like._SupportsArray[numpy.dtype[Any]] | numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]] | builtins.complex | builtins.bytes | builtins.str | numpy._typing._nested_sequence._NestedSequence[builtins.complex | builtins.bytes | builtins.str] | typing.Sequence[tuple[builtins.float, builtins.float, builtins.float] | builtins.str | builtins.str | tuple[builtins.float, builtins.float, builtins.float, builtins.float] | tuple[tuple[builtins.float, builtins.float, builtins.float] | builtins.str, builtins.float] | tuple[tuple[builtins.float, builtins.float, builtins.float, builtins.float], builtins.float]] | tuple[builtins.float, builtins.float, builtins.float] | builtins.str | builtins.str | tuple[builtins.float, builtins.float, builtins.float, builtins.float] | tuple[tuple[builtins.float, builtins.float, builtins.float] | builtins.str, builtins.float] | tuple[tuple[builtins.float, builtins.float, builtins.float, builtins.float], builtins.float] | None =, *, marker: matplotlib.path.Path | matplotlib.markers.MarkerStyle | builtins.str | Literal['.'] | Literal[','] | Literal['o'] | Literal['v'] | Literal['^'] | Literal['<'] | Literal['>'] | Literal['1'] | Literal['2'] | Literal['3'] | Literal['4'] | Literal['8'] | Literal['s'] | Literal['p'] | Literal['P'] | Literal['*'] | Literal['h'] | Literal['H'] | Literal['+'] | Literal['x'] | Literal['X'] | Literal['D'] | Literal['d'] | Literal['|'] | Literal['_'] | Literal['none'] | Literal[' '] | Literal[0] | Literal[1] | Literal[2] | Literal[3] | Literal[4] | Literal[5] | Literal[6] | Literal[7] | Literal[8] | Literal[9] | Literal[10] | Literal[11] | builtins.list[tuple[builtins.int, builtins.int]] | tuple[builtins.int, Literal[0] | Literal[1] | Literal[2], builtins.int] | None =, cmap: builtins.str | matplotlib.colors.Colormap | None =, norm: builtins.str | matplotlib.colors.Normalize | None =, vmin: builtins.float | None =, vmax: builtins.float | None =, alpha: builtins.float | None =, linewidths: builtins.float | typing.Sequence[builtins.float] | None =, edgecolors: Literal['face'] | Literal['none'] | tuple[builtins.float, builtins.float, builtins.float] | builtins.str | builtins.str | tuple[builtins.float, builtins.float, builtins.float, builtins.float] | tuple[tuple[builtins.float, builtins.f
self,
x: float | ArrayLike,
y: float | ArrayLike,
z: float | ArrayLike,
s: float | ArrayLike | None = ...,
c: ArrayLike | Sequence[ColorType] | ColorType | None = ...,
*,
Expand Down
4 changes: 2 additions & 2 deletionslib/matplotlib/axes/_base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -550,8 +550,8 @@
# In practice, this is ('x', 'y') for all 2D Axes and ('x', 'y', 'z')
# for Axes3D.
_axis_names = ("x", "y")
_shared_axes = {name: cbook.Grouper() for name in _axis_names}
_twinned_axes = cbook.Grouper()
_shared_axes: dict[str, cbook.Grouper] = {name: cbook.Grouper() for name in _axis_names}

Check warning on line 553 in lib/matplotlib/axes/_base.py

View workflow job for this annotation

GitHub Actions/ ruff

[rdjson] reported by reviewdog 🐶Line too long (92 > 88)Raw Output:message:"Line too long (92 > 88)" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/matplotlib/axes/_base.py" range:{start:{line:553 column:89} end:{line:553 column:93}}} severity:WARNING source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"E501" url:"https://docs.astral.sh/ruff/rules/line-too-long"}
_twinned_axes: cbook.Grouper = cbook.Grouper()

_subclass_uses_cla = False

Expand Down
64 changes: 64 additions & 0 deletionslib/matplotlib/axes/_base.pyi
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,6 +41,60 @@ class _axis_method_wrapper:
) -> None: ...
def __set_name__(self, owner: Any, name: str) -> None: ...

class _TransformedBoundsLocator:
_bounds: Sequence[float]
_transform: Transform

def __init__(self, bounds: Sequence[float], transform: Transform) -> None: ...

def __call__(self, ax: Any, renderer: Any) -> Bbox: ...
Comment on lines +48 to +50
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Don't need the blank lines between methods in type stubs.



def _process_plot_format(
fmt: str,
*,
ambiguous_fmt_datakey: bool = False
) -> tuple[str | None, str | None, ColorType | None]: ...

class _process_plot_var_args:
output: str

def __init__(self, output: str = ...) -> None: ...

def set_prop_cycle(self, cycler: Any) -> None: ...

def __call__(
self,
axes: Any,
*args: Any,
data: Any | None = ...,
return_kwargs: bool = ...,
**kwargs: Any,
) -> Iterator[Any]: ...

def get_next_color(self) -> Any: ...

def _getdefaults(self, kw: dict[str, Any], ignore: Any = ...) -> dict[str, Any]: ...

def _setdefaults(self, defaults: dict[str, Any], kw: dict[str, Any]) -> None: ...

def _make_line(self, axes: Any, x: Any, y: Any, kw: dict[str, Any], kwargs: dict[str, Any]) -> tuple[Any, dict[str, Any]]: ...

def _make_coordinates(self, axes: Any, x: Any, y: Any, kw: dict[str, Any], kwargs: dict[str, Any]) -> tuple[Any, dict[str, Any]]: ...

def _make_polygon(self, axes: Any, x: Any, y: Any, kw: dict[str, Any], kwargs: dict[str, Any]) -> tuple[Any, dict[str, Any]]: ...

def _plot_args(
self,
axes: Any,
tup: tuple[Any, ...],
kwargs: dict[str, Any],
*,
return_kwargs: bool = ...,
ambiguous_fmt_datakey: bool = ...,
) -> Iterator[Any]: ...


class _AxesBase(martist.Artist):
name: str
patch: Patch
Expand All@@ -64,6 +118,9 @@ class _AxesBase(martist.Artist):
title: Text
_axis_map: dict[str, Axis]
_projection_init: Any
_axis_names: tuple[Literal['x'], Literal['y']] | tuple[Literal['x'], Literal['y'], Literal['z']]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This type is definitely not literals.

_shared_axes: dict[str, cbook.Grouper]
_twinned_axes: list[cbook.Grouper]

def __init__(
self,
Expand DownExpand Up@@ -462,3 +519,10 @@ class _AxesBase(martist.Artist):
) -> list[Text]: ...
def xaxis_date(self, tz: str | datetime.tzinfo | None = ...) -> None: ...
def yaxis_date(self, tz: str | datetime.tzinfo | None = ...) -> None: ...


def _draw_rasterized(
figure: Figure,
artists: list[Artist],
renderer: RendererBase,
) -> None: ...
41 changes: 25 additions & 16 deletionslib/mpl_toolkits/mplot3d/axes3d.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,7 +70,7 @@
----------
fig : Figure
The parent figure.
rect : tuple (left, bottom, width, height), default:(0, 0, 1, 1)
rect : tuple (left, bottom, width, height), default:None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This change is unrelated, and incorrect.

The ``(left, bottom, width, height)`` Axes position.
elev : float, default: 30
The elevation angle in degrees rotates the camera above and below
Expand DownExpand Up@@ -246,7 +246,7 @@

@_api.delete_parameter("3.11", "share")
@_api.delete_parameter("3.11", "anchor")
def set_aspect(self, aspect, adjustable=None, anchor=None, share=False):
def set_aspect(self, aspect, adjustable=None):
"""
Set the aspect ratios.

Expand DownExpand Up@@ -663,10 +663,10 @@

def get_w_lims(self):
"""Get 3D world limits."""
minx, maxx = self.get_xlim3d()
miny, maxy = self.get_ylim3d()
minz, maxz = self.get_zlim3d()
return minx, maxx, miny, maxy, minz, maxz
minx, maxx = self.get_xlim()
miny, maxy = self.get_ylim()
minz, maxz = self.get_zlim()
return(minx, maxx, miny, maxy, minz, maxz)

def _set_bound3d(self, get_bound, set_lim, axis_inverted,
lower=None, upper=None, view_margin=None):
Expand DownExpand Up@@ -1013,7 +1013,7 @@

def get_xlim(self):
# docstring inherited
returntuple(self.xy_viewLim.intervalx)
return (self.xy_viewLim.intervalx)

def get_ylim(self):
# docstring inherited
Expand DownExpand Up@@ -1192,7 +1192,7 @@
self._focal_length = np.inf

def _roll_to_vertical(
self, arr: "np.typing.ArrayLike", reverse: bool = False
self, arr, reverse: bool = False
) -> np.ndarray:
"""
Roll arrays to match the different vertical axis.
Expand All@@ -1215,9 +1215,9 @@
# Transform to uniform world coordinates 0-1, 0-1, 0-1
box_aspect = self._roll_to_vertical(self._box_aspect)
worldM = proj3d.world_transformation(
*self.get_xlim3d(),
*self.get_ylim3d(),
*self.get_zlim3d(),
*self.get_xlim(),
*self.get_ylim(),
*self.get_zlim(),
pb_aspect=box_aspect,
)

Expand DownExpand Up@@ -1502,7 +1502,7 @@
p2 = p1 - scale*vec
return p2, pane_idx

def _arcball(self, x: float, y: float) -> np.ndarray:
def _arcball(self, x, y):
"""
Convert a point (x, y) to a point on a virtual trackball.

Expand DownExpand Up@@ -1808,7 +1808,7 @@
dx = (maxx - minx)
dy = (maxy - miny)
dz = (maxz - minz)
return cx, cy, cz, dx, dy, dz
return(cx, cy, cz, dx, dy, dz)

def set_zlabel(self, zlabel, fontdict=None, labelpad=None, **kwargs):
"""
Expand DownExpand Up@@ -2559,9 +2559,18 @@

return polyc

def _3d_extend_contour(self, cset, stride=5):
def _3d_extend_contour(self, cset, stride = 5) -> None:

Check warning on line 2562 in lib/mpl_toolkits/mplot3d/axes3d.py

View workflow job for this annotation

GitHub Actions/ ruff

[rdjson] reported by reviewdog 🐶Unexpected spaces around keyword / parameter equalsRaw Output:message:"Unexpected spaces around keyword / parameter equals" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py" range:{start:{line:2562 column:48} end:{line:2562 column:49}}} severity:WARNING source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"E251" url:"https://docs.astral.sh/ruff/rules/unexpected-spaces-around-keyword-parameter-equals"} suggestions:{range:{start:{line:2562 column:48} end:{line:2562 column:49}}}

Check warning on line 2562 in lib/mpl_toolkits/mplot3d/axes3d.py

View workflow job for this annotation

GitHub Actions/ ruff

[rdjson] reported by reviewdog 🐶Unexpected spaces around keyword / parameter equalsRaw Output:message:"Unexpected spaces around keyword / parameter equals" location:{path:"/home/runner/work/matplotlib/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py" range:{start:{line:2562 column:46} end:{line:2562 column:47}}} severity:WARNING source:{name:"ruff" url:"https://docs.astral.sh/ruff"} code:{value:"E251" url:"https://docs.astral.sh/ruff/rules/unexpected-spaces-around-keyword-parameter-equals"} suggestions:{range:{start:{line:2562 column:46} end:{line:2562 column:47}}}
"""
Extend a contour in 3D by creating
Extend a 2D contour set into 3D space by generating vertical faces between
contour levels.

Parameters
----------
cset : matplotlib.contour.QuadContourSet
The contour set (returned by plt.contour or ax.contour) whose levels
and paths will be extended into 3D.
stride : int, optional
Sampling stride for contour segments to reduce polygon count.
"""

dz = (cset.levels[1] - cset.levels[0]) / 2
Expand DownExpand Up@@ -2986,7 +2995,7 @@
if np.may_share_memory(zs_orig, zs): # Avoid unnecessary copies.
zs = zs.copy()

patches = super().scatter(xs, ys, s=s, c=c, *args, **kwargs)
patches = super().scatter(xs, ys,zs,s=s, c=c, *args, **kwargs)
art3d.patch_collection_2d_to_3d(
patches,
zs=zs,
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp