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

DOC: Add descriptions to matplotlib.typing#29918

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

Merged
timhoffm merged 1 commit intomatplotlib:mainfromtimhoffm:doc-typing
May 1, 2025
Merged
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
23 changes: 19 additions & 4 deletionsdoc/api/typing_api.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,18 +2,33 @@
``matplotlib.typing``
*********************

.. automodule:: matplotlib.typing
:no-members:
:no-undoc-members:

Color
=====

.. autodata:: matplotlib.typing.ColorType
.. autodata:: matplotlib.typing.RGBColorType
.. autodata:: matplotlib.typing.RGBColourType
.. autodata:: matplotlib.typing.RGBAColorType
.. autodata:: matplotlib.typing.RGBAColourType
.. autodata:: matplotlib.typing.ColorType
.. autodata:: matplotlib.typing.ColourType
.. autodata:: matplotlib.typing.RGBColourType
.. autodata:: matplotlib.typing.RGBAColourType
Comment on lines 15 to +17
Copy link
Member

Choose a reason for hiding this comment

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

These seem to need docstrings, even if they are just "Alias of ...", because right now they are the rather unclear "Represent a PEP 604 union type".

Also, any idea why these colour types seem to get the type alias in bold next to the name, whereas the style ones seem to get "alias of ..." in the description instead?

Copy link
MemberAuthor

@timhoffmtimhoffmApr 16, 2025
edited
Loading

Choose a reason for hiding this comment

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

I've noted this as well, but decided to not bother right now. I don't want to spend time on it, and it's not getting worse through the PR.

There must be some issue in autodoc. If that gets fixed, we should get the right description automatically.

More fundamentally, why do we need these aliases? All our function/parameter names use "color" and we don't alias them. I'm tempted to remove the aliases here (only leaving them for now because as said, I don't want to spend much time on this)

Copy link
Member

Choose a reason for hiding this comment

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

If I had my way, I'd have the colour spelling available everywhere, but I don't remember why these specifically are here.

Copy link
MemberAuthor

@timhoffmtimhoffmMay 1, 2025
edited
Loading

Choose a reason for hiding this comment

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

I've add docstrings to the aliases for now. Though, I'd propose to remove the aliases because AFAIK we don't have aliases anywhere else in the API. But that's a separeate discussion.


Styles
======

.. autodata:: matplotlib.typing.LineStyleType
.. autodata:: matplotlib.typing.DrawStyleType
.. autodata:: matplotlib.typing.MarkEveryType
.. autodata:: matplotlib.typing.FillStyleType
.. autodata:: matplotlib.typing.CapStyleType
.. autodata:: matplotlib.typing.JoinStyleType

Other types
===========

.. autodata:: matplotlib.typing.CoordsType
.. autodata:: matplotlib.typing.RcStyleType
.. autodata:: matplotlib.typing.HashableList
:annotation: Nested list with Hashable values
29 changes: 28 additions & 1 deletionlib/matplotlib/typing.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,8 @@
This module contains Type aliases which are useful for Matplotlib and potentially
downstream libraries.

.. admonition:: Provisional status of typing
.. warning::
**Provisional status of typing**

The ``typing`` module and type stub files are considered provisional and may change
at any time without a deprecation period.
Expand All@@ -21,6 +22,8 @@
from .transforms import Bbox, Transform

RGBColorType: TypeAlias = tuple[float, float, float] | str
"""Any RGB color specification accepted by Matplotlib."""

RGBAColorType: TypeAlias = (
str | # "none" or "#RRGGBBAA"/"#RGBA" hex strings
tuple[float, float, float, float] |
Expand All@@ -30,31 +33,55 @@
# (4-tuple, float) is odd, but accepted as the outer float overriding A of 4-tuple
tuple[tuple[float, float, float, float], float]
)
"""Any RGBA color specification accepted by Matplotlib."""

ColorType: TypeAlias = RGBColorType | RGBAColorType
"""Any color specification accepted by Matplotlib. See :mpltype:`color`."""

RGBColourType: TypeAlias = RGBColorType
"""Alias of `.RGBColorType`."""

RGBAColourType: TypeAlias = RGBAColorType
"""Alias of `.RGBAColorType`."""

ColourType: TypeAlias = ColorType
"""Alias of `.ColorType`."""

LineStyleType: TypeAlias = (
Literal["-", "solid", "--", "dashed", "-.", "dashdot", ":", "dotted",
"", "none", " ", "None"] |
tuple[float, Sequence[float]]
)
"""
Any line style specification accepted by Matplotlib.
See :doc:`/gallery/lines_bars_and_markers/linestyles`.
"""

DrawStyleType: TypeAlias = Literal["default", "steps", "steps-pre", "steps-mid",
"steps-post"]
"""See :doc:`/gallery/lines_bars_and_markers/step_demo`."""

MarkEveryType: TypeAlias = (
None |
int | tuple[int, int] | slice | list[int] |
float | tuple[float, float] |
list[bool]
)
"""See :doc:`/gallery/lines_bars_and_markers/markevery_demo`."""

MarkerType: TypeAlias = str | path.Path | MarkerStyle
"""
Marker specification. See :doc:`/gallery/lines_bars_and_markers/marker_reference`.
"""

FillStyleType: TypeAlias = Literal["full", "left", "right", "bottom", "top", "none"]
"""Marker fill styles. See :doc:`/gallery/lines_bars_and_markers/marker_reference`."""

JoinStyleType: TypeAlias = JoinStyle | Literal["miter", "round", "bevel"]
"""Line join styles. See :doc:`/gallery/lines_bars_and_markers/joinstyle`."""

CapStyleType: TypeAlias = CapStyle | Literal["butt", "projecting", "round"]
"""Line cap styles. See :doc:`/gallery/lines_bars_and_markers/capstyle`."""

CoordsBaseType = Union[
str,
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp