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

Skip to content

Commit 9bf4e14

Browse files
committed
Reorganize to typing.py, rename Color to ColorType
1 parent 3d23775 commit 9bf4e14

31 files changed

+257
-254
lines changed

lib/matplotlib/_color_data.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from .colors import Color
1+
from .typing import ColorType
22

3-
BASE_COLORS: dict[str, Color]
4-
TABLEAU_COLORS: dict[str, Color]
5-
XKCD_COLORS: dict[str, Color]
6-
CSS4_COLORS: dict[str, Color]
3+
BASE_COLORS: dict[str, ColorType]
4+
TABLEAU_COLORS: dict[str, ColorType]
5+
XKCD_COLORS: dict[str, ColorType]
6+
CSS4_COLORS: dict[str, ColorType]

lib/matplotlib/axes/_axes.pyi

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ from matplotlib.collections import (
1212
EventCollection,
1313
QuadMesh,
1414
)
15-
from matplotlib.colors import Color, Colormap, Normalize
15+
from matplotlib.colors import Colormap, Normalize
1616
from matplotlib.container import BarContainer, ErrorbarContainer, StemContainer
1717
from matplotlib.contour import ContourSet, QuadContourSet
1818
from matplotlib.image import AxesImage, PcolorImage
1919
from matplotlib.legend import Legend
2020
from matplotlib.legend_handler import HandlerBase
21-
from matplotlib.lines import Line2D, LineStyleType
22-
from matplotlib.markers import MarkerType
21+
from matplotlib.lines import Line2D
2322
from matplotlib.mlab import GaussianKDE
2423
from matplotlib.patches import Rectangle, FancyArrow, Polygon, StepPatch
2524
from matplotlib.quiver import Quiver, QuiverKey, Barbs
@@ -36,6 +35,7 @@ from collections.abc import Callable, Sequence
3635
from typing import Any, Literal, overload
3736
import numpy as np
3837
from numpy.typing import ArrayLike
38+
from matplotlib.typing import ColorType, MarkerType, LineStyleType
3939

4040
class Axes(_AxesBase):
4141
def get_title(self, loc: Literal["left", "center", "right"] = ...) -> str: ...
@@ -77,8 +77,8 @@ class Axes(_AxesBase):
7777
inset_ax: Axes | None = ...,
7878
*,
7979
transform: Transform | None = ...,
80-
facecolor: Color = ...,
81-
edgecolor: Color = ...,
80+
facecolor: ColorType = ...,
81+
edgecolor: ColorType = ...,
8282
alpha: float = ...,
8383
zorder: float = ...,
8484
**kwargs
@@ -161,7 +161,7 @@ class Axes(_AxesBase):
161161
y: float | ArrayLike,
162162
xmin: float | ArrayLike,
163163
xmax: float | ArrayLike,
164-
colors: Sequence[Color] | None = ...,
164+
colors: Sequence[ColorType] | None = ...,
165165
linestyles: LineStyleType = ...,
166166
label: str = ...,
167167
**kwargs
@@ -171,7 +171,7 @@ class Axes(_AxesBase):
171171
x: float | ArrayLike,
172172
ymin: float | ArrayLike,
173173
ymax: float | ArrayLike,
174-
colors: Sequence[Color] | None = ...,
174+
colors: Sequence[ColorType] | None = ...,
175175
linestyles: LineStyleType = ...,
176176
label: str = ...,
177177
**kwargs
@@ -183,7 +183,7 @@ class Axes(_AxesBase):
183183
lineoffsets: float | Sequence[float] = ...,
184184
linelengths: float | Sequence[float] = ...,
185185
linewidths: float | Sequence[float] | None = ...,
186-
colors: Color | Sequence[Color] | None = ...,
186+
colors: ColorType | Sequence[ColorType] | None = ...,
187187
alpha: float | Sequence[float] | None = ...,
188188
linestyles: LineStyleType | Sequence[LineStyleType] = ...,
189189
**kwargs
@@ -286,7 +286,7 @@ class Axes(_AxesBase):
286286
x: ArrayLike,
287287
explode: ArrayLike | None = ...,
288288
labels: Sequence[str] | None = ...,
289-
colors: Sequence[Color] | None = ...,
289+
colors: Sequence[ColorType] | None = ...,
290290
autopct: str | Callable[[float], str] | None = ...,
291291
pctdistance: float = ...,
292292
shadow: bool = ...,
@@ -310,7 +310,7 @@ class Axes(_AxesBase):
310310
yerr: float | ArrayLike | None = ...,
311311
xerr: float | ArrayLike | None = ...,
312312
fmt: str = ...,
313-
ecolor: Color | None = ...,
313+
ecolor: ColorType | None = ...,
314314
elinewidth: float | None = ...,
315315
capsize: float | None = ...,
316316
barsabove: bool = ...,
@@ -380,7 +380,7 @@ class Axes(_AxesBase):
380380
x: float | ArrayLike,
381381
y: float | ArrayLike,
382382
s: float | ArrayLike | None = ...,
383-
c: Sequence[Color] | Color | None = ...,
383+
c: Sequence[ColorType] | ColorType | None = ...,
384384
marker: MarkerType | None = ...,
385385
cmap: str | Colormap | None = ...,
386386
norm: str | Normalize | None = ...,
@@ -389,7 +389,7 @@ class Axes(_AxesBase):
389389
alpha: float | None = ...,
390390
linewidths: float | Sequence[float] | None = ...,
391391
*,
392-
edgecolors: Literal["face", "none"] | Color | Sequence[Color] | None = ...,
392+
edgecolors: Literal["face", "none"] | ColorType | Sequence[ColorType] | None = ...,
393393
plotnonfinite: bool = ...,
394394
**kwargs
395395
) -> PathCollection: ...
@@ -409,7 +409,7 @@ class Axes(_AxesBase):
409409
vmax: float | None = ...,
410410
alpha: float | None = ...,
411411
linewidths: float | None = ...,
412-
edgecolors: Literal["face", "none"] | Color = ...,
412+
edgecolors: Literal["face", "none"] | ColorType = ...,
413413
reduce_C_function: Callable[[np.ndarray], float] = ...,
414414
mincnt: int | None = ...,
415415
marginals: bool = ...,
@@ -516,7 +516,7 @@ class Axes(_AxesBase):
516516
orientation: Literal["vertical", "horizontal"] = ...,
517517
rwidth: float | None = ...,
518518
log: bool = ...,
519-
color: Color | Sequence[Color] | None = ...,
519+
color: ColorType | Sequence[ColorType] | None = ...,
520520
label: str | Sequence[str] | None = ...,
521521
stacked: bool = ...,
522522
**kwargs

lib/matplotlib/axes/_base.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ from matplotlib.backend_bases import RendererBase, MouseButton, MouseEvent
99
from matplotlib.cbook import index_of
1010
from matplotlib.container import Container
1111
from matplotlib.collections import Collection
12-
from matplotlib.colors import Color
1312
from matplotlib.cm import ScalarMappable
1413
from matplotlib.legend import Legend
1514
from matplotlib.lines import Line2D
@@ -29,6 +28,7 @@ from cycler import Cycler
2928
import numpy as np
3029
from numpy.typing import ArrayLike
3130
from typing import Any, Literal, overload
31+
from matplotlib.typing import ColorType
3232

3333
class _axis_method_wrapper:
3434
attr_name: str
@@ -57,7 +57,7 @@ class _AxesBase(martist.Artist):
5757
self,
5858
fig: Figure,
5959
*args: tuple[float, float, float, float] | Bbox | int,
60-
facecolor: Color | None = ...,
60+
facecolor: ColorType | None = ...,
6161
frameon: bool = ...,
6262
sharex: _AxesBase | None = ...,
6363
sharey: _AxesBase | None = ...,
@@ -167,8 +167,8 @@ class _AxesBase(martist.Artist):
167167
def tables(self) -> _AxesBase.ArtistList: ...
168168
@property
169169
def texts(self) -> _AxesBase.ArtistList: ...
170-
def get_facecolor(self) -> Color: ...
171-
def set_facecolor(self, color: Color | None) -> None: ...
170+
def get_facecolor(self) -> ColorType: ...
171+
def set_facecolor(self, color: ColorType | None) -> None: ...
172172
@overload
173173
def set_prop_cycle(self, cycler: Cycler) -> None: ...
174174
@overload

lib/matplotlib/axes/_secondary_axes.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from matplotlib.axes._base import _AxesBase
22
from matplotlib.axis import Axis, Tick
33

4-
from matplotlib.colors import Color
54
from matplotlib.transforms import Transform
65

76
from collections.abc import Callable, Iterable
87
from typing import Literal
98
from numpy.typing import ArrayLike
9+
from matplotlib.typing import ColorType
1010

1111
class SecondaryAxis(_AxesBase):
1212
def __init__(
@@ -42,4 +42,4 @@ class SecondaryAxis(_AxesBase):
4242
| Transform,
4343
): ...
4444
def set_aspect(self, *args, **kwargs) -> None: ...
45-
def set_color(self, color: Color) -> None: ...
45+
def set_color(self, color: ColorType) -> None: ...

lib/matplotlib/axis.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import matplotlib.artist as martist
22
from matplotlib import cbook
33
from matplotlib.axes import Axes
44
from matplotlib.backend_bases import RendererBase
5-
from matplotlib.colors import Color
65
from matplotlib.lines import Line2D
76
from matplotlib.text import Text
87
from matplotlib.ticker import Locator, Formatter
@@ -13,6 +12,7 @@ from collections.abc import Callable, Iterable
1312
from typing import Any, Literal
1413
import numpy as np
1514
from numpy.typing import ArrayLike
15+
from matplotlib.typing import ColorType
1616

1717

1818
GRIDLINE_INTERPOLATION_STEPS: int
@@ -31,11 +31,11 @@ class Tick(martist.Artist):
3131
*,
3232
size: float | None = ...,
3333
width: float | None = ...,
34-
color: Color | None = ...,
34+
color: ColorType | None = ...,
3535
tickdir: Literal["in", "inout", "out"] | None = ...,
3636
pad: float | None = ...,
3737
labelsize: float | None = ...,
38-
labelcolor: Color | None = ...,
38+
labelcolor: ColorType | None = ...,
3939
zorder: float | None = ...,
4040
gridOn: bool | None = ...,
4141
tick1On: bool = ...,
@@ -44,7 +44,7 @@ class Tick(martist.Artist):
4444
label2On: bool = ...,
4545
major: bool = ...,
4646
labelrotation: float = ...,
47-
grid_color: Color | None = ...,
47+
grid_color: ColorType | None = ...,
4848
grid_linestyle: str | None = ...,
4949
grid_linewidth: float | None = ...,
5050
grid_alpha: float | None = ...,

lib/matplotlib/backend_bases.pyi

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ from matplotlib.axes import Axes
1919
from matplotlib.backend_managers import ToolManager
2020
from matplotlib.backend_tools import Cursors, ToolBase
2121
from matplotlib.colorbar import Colorbar
22-
from matplotlib.colors import Color
2322
from matplotlib.figure import Figure
2423
from matplotlib.font_manager import FontProperties
25-
from matplotlib.lines import LineStyleType
2624
from matplotlib.path import Path
2725
from matplotlib.texmanager import TexManager
2826
from matplotlib.text import Text
@@ -31,6 +29,7 @@ from matplotlib.transforms import Affine2D, Transform, TransformedPath, Bbox
3129
from collections.abc import Callable, Sequence
3230
from typing import Any, Literal, NamedTuple, TypeVar
3331
from numpy.typing import ArrayLike
32+
from .typing import ColorType, LineStyleType
3433

3534
def register_backend(
3635
format: str, backend: str | type[FigureCanvasBase], description: str | None = ...
@@ -46,7 +45,7 @@ class RendererBase:
4645
gc: GraphicsContextBase,
4746
path: Path,
4847
transform: Transform,
49-
rgbFace: Color | None = ...,
48+
rgbFace: ColorType | None = ...,
5049
) -> None: ...
5150
def draw_markers(
5251
self,
@@ -55,7 +54,7 @@ class RendererBase:
5554
marker_trans: Transform,
5655
path: Path,
5756
trans: Transform,
58-
rgbFace: Color | None = ...,
57+
rgbFace: ColorType | None = ...,
5958
) -> None: ...
6059
def draw_path_collection(
6160
self,
@@ -65,8 +64,8 @@ class RendererBase:
6564
all_transforms: Sequence[ArrayLike],
6665
offsets: ArrayLike | Sequence[ArrayLike],
6766
offset_trans: Transform,
68-
facecolors: Color | Sequence[Color],
69-
edgecolors: Color | Sequence[Color],
67+
facecolors: ColorType | Sequence[ColorType],
68+
edgecolors: ColorType | Sequence[ColorType],
7069
linewidths: float | Sequence[float],
7170
linestyles: LineStyleType | Sequence[LineStyleType],
7271
antialiaseds: bool | Sequence[bool],
@@ -82,9 +81,9 @@ class RendererBase:
8281
coordinates: ArrayLike,
8382
offsets: ArrayLike | Sequence[ArrayLike],
8483
offsetTrans: Transform,
85-
facecolors: Sequence[Color],
84+
facecolors: Sequence[ColorType],
8685
antialiased: bool,
87-
edgecolors: Sequence[Color] | Color | None,
86+
edgecolors: Sequence[ColorType] | ColorType | None,
8887
): ...
8988
def draw_gouraud_triangle(
9089
self,
@@ -171,7 +170,7 @@ class GraphicsContextBase:
171170
def set_clip_rectangle(self, rectangle: Bbox | None) -> None: ...
172171
def set_clip_path(self, path: TransformedPath | None) -> None: ...
173172
def set_dashes(self, dash_offset: float, dash_list: ArrayLike | None) -> None: ...
174-
def set_foreground(self, fg: Color, isRGBA: bool = ...) -> None: ...
173+
def set_foreground(self, fg: ColorType, isRGBA: bool = ...) -> None: ...
175174
def set_joinstyle(self, js: JoinStyle) -> None: ...
176175
def set_linewidth(self, w: float) -> None: ...
177176
def set_url(self, url: str | None) -> None: ...
@@ -180,8 +179,8 @@ class GraphicsContextBase:
180179
def set_hatch(self, hatch: str) -> None: ...
181180
def get_hatch(self) -> str | None: ...
182181
def get_hatch_path(self, density: float = ...) -> Path: ...
183-
def get_hatch_color(self) -> Color: ...
184-
def set_hatch_color(self, hatch_color: Color) -> None: ...
182+
def get_hatch_color(self) -> ColorType: ...
183+
def set_hatch_color(self, hatch_color: ColorType) -> None: ...
185184
def get_hatch_linewidth(self) -> float: ...
186185
def get_sketch_params(self) -> tuple[float, float, float] | None: ...
187186
def set_sketch_params(
@@ -345,8 +344,8 @@ class FigureCanvasBase:
345344
self,
346345
filename: str | os.PathLike | io.FileIO,
347346
dpi: float | None = ...,
348-
facecolor: Color | Literal["auto"] | None = ...,
349-
edgecolor: Color | Literal["auto"] | None = ...,
347+
facecolor: ColorType | Literal["auto"] | None = ...,
348+
edgecolor: ColorType | Literal["auto"] | None = ...,
350349
orientation: str = ...,
351350
format: str | None = ...,
352351
*,

lib/matplotlib/collections.pyi

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from . import artist, cbook, cm, transforms
22
from .backend_bases import MouseEvent
33
from .artist import Artist
4-
from .colors import Color, Normalize, Colormap
5-
from .lines import LineStyleType
4+
from .colors import Normalize, Colormap
65
from .path import Path
76
from .patches import Patch
87
from .ticker import Locator, Formatter
@@ -13,12 +12,13 @@ import numpy as np
1312
from numpy.typing import ArrayLike
1413
from collections.abc import Callable, Iterable, Sequence
1514
from typing import Literal
15+
from .typing import ColorType, LineStyleType
1616

1717
class Collection(artist.Artist, cm.ScalarMappable):
1818
def __init__(
1919
self,
20-
edgecolors: Color | Sequence[Color] | None = ...,
21-
facecolors: Color | Sequence[Color] | None = ...,
20+
edgecolors: ColorType | Sequence[ColorType] | None = ...,
21+
facecolors: ColorType | Sequence[ColorType] | None = ...,
2222
linewidths: float | Sequence[float] | None = ...,
2323
linestyles: LineStyleType | Sequence[LineStyleType] = ...,
2424
capstyle: CapStyle | None = ...,
@@ -56,11 +56,11 @@ class Collection(artist.Artist, cm.ScalarMappable):
5656
def set_joinstyle(self, js: JoinStyle | Sequence[JoinStyle]) -> None: ...
5757
def get_joinstyle(self) -> JoinStyle | Sequence[JoinStyle]: ...
5858
def set_antialiased(self, aa: bool | Sequence[bool]) -> None: ...
59-
def set_color(self, c: Color | Sequence[Color]) -> None: ...
60-
def set_facecolor(self, c: Color | Sequence[Color]) -> None: ...
61-
def get_facecolor(self) -> Color | Sequence[Color]: ...
62-
def get_edgecolor(self) -> Color | Sequence[Color]: ...
63-
def set_edgecolor(self, c: Color | Sequence[Color]) -> None: ...
59+
def set_color(self, c: ColorType | Sequence[ColorType]) -> None: ...
60+
def set_facecolor(self, c: ColorType | Sequence[ColorType]) -> None: ...
61+
def get_facecolor(self) -> ColorType | Sequence[ColorType]: ...
62+
def get_edgecolor(self) -> ColorType | Sequence[ColorType]: ...
63+
def set_edgecolor(self, c: ColorType | Sequence[ColorType]) -> None: ...
6464
def set_alpha(self, alpha: float | Sequence[float] | None) -> None: ...
6565
def get_linewidth(self) -> float | Sequence[float]: ...
6666
def get_linestyle(self) -> LineStyleType | Sequence[LineStyleType]: ...
@@ -133,10 +133,10 @@ class LineCollection(Collection):
133133
def set_verts(self, segments: Sequence[ArrayLike] | None) -> None: ...
134134
def set_paths(self, segments: Sequence[ArrayLike] | None) -> None: ... # type: ignore[override]
135135
def get_segments(self) -> list[np.ndarray]: ...
136-
def set_color(self, c: Color | Sequence[Color]) -> None: ...
137-
def set_colors(self, c: Color | Sequence[Color]) -> None: ...
138-
def get_color(self) -> Color | Sequence[Color]: ...
139-
def get_colors(self) -> Color | Sequence[Color]: ...
136+
def set_color(self, c: ColorType | Sequence[ColorType]) -> None: ...
137+
def set_colors(self, c: ColorType | Sequence[ColorType]) -> None: ...
138+
def get_color(self) -> ColorType | Sequence[ColorType]: ...
139+
def get_colors(self) -> ColorType | Sequence[ColorType]: ...
140140

141141
class EventCollection(LineCollection):
142142
def __init__(
@@ -146,7 +146,7 @@ class EventCollection(LineCollection):
146146
lineoffset: float = ...,
147147
linelength: float = ...,
148148
linewidth: float | Sequence[float] | None = ...,
149-
color: Color | Sequence[Color] | None = ...,
149+
color: ColorType | Sequence[ColorType] | None = ...,
150150
linestyle: LineStyleType | Sequence[LineStyleType] = ...,
151151
antialiased: bool | Sequence[bool] | None = ...,
152152
**kwargs
@@ -168,7 +168,7 @@ class EventCollection(LineCollection):
168168
def set_lineoffset(self, lineoffset: float) -> None: ...
169169
def get_linewidth(self) -> float: ...
170170
def get_linewidths(self) -> Sequence[float]: ...
171-
def get_color(self) -> Color: ...
171+
def get_color(self) -> ColorType: ...
172172

173173
class CircleCollection(_CollectionWithSizes):
174174
def __init__(self, sizes: float | ArrayLike, **kwargs) -> None: ...

0 commit comments

Comments
 (0)