Skip to content

Commit 2d53520

Browse files
authored
Merge pull request matplotlib#31482 from timhoffm/typ-data
TYP: Add type information to the data parameter of plot functions
2 parents 319174c + 71facf6 commit 2d53520

3 files changed

Lines changed: 84 additions & 79 deletions

File tree

lib/matplotlib/axes/_axes.pyi

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ from collections.abc import Callable, Iterable, Sequence
3838
from typing import Any, Literal, overload
3939
import numpy as np
4040
from numpy.typing import ArrayLike
41-
from matplotlib.typing import ColorType, MarkerType, LegendLocType, LineStyleType
41+
from matplotlib.typing import (
42+
ColorType, DataParamType, MarkerType, LegendLocType, LineStyleType)
4243
import pandas as pd
4344

4445

@@ -173,7 +174,7 @@ class Axes(_AxesBase):
173174
linestyles: LineStyleType = ...,
174175
*,
175176
label: str = ...,
176-
data=...,
177+
data: DataParamType = ...,
177178
**kwargs
178179
) -> LineCollection: ...
179180
def vlines(
@@ -185,7 +186,7 @@ class Axes(_AxesBase):
185186
linestyles: LineStyleType = ...,
186187
*,
187188
label: str = ...,
188-
data=...,
189+
data: DataParamType = ...,
189190
**kwargs
190191
) -> LineCollection: ...
191192
def eventplot(
@@ -199,22 +200,22 @@ class Axes(_AxesBase):
199200
colors: ColorType | Sequence[ColorType] | None = ...,
200201
alpha: float | Sequence[float] | None = ...,
201202
linestyles: LineStyleType | Sequence[LineStyleType] = ...,
202-
data=...,
203+
data: DataParamType = ...,
203204
**kwargs
204205
) -> EventCollection: ...
205206
def plot(
206207
self,
207208
*args: float | ArrayLike | str,
208209
scalex: bool = ...,
209210
scaley: bool = ...,
210-
data=...,
211+
data: DataParamType = ...,
211212
**kwargs
212213
) -> list[Line2D]: ...
213214
def loglog(self, *args, **kwargs) -> list[Line2D]: ...
214215
def semilogx(self, *args, **kwargs) -> list[Line2D]: ...
215216
def semilogy(self, *args, **kwargs) -> list[Line2D]: ...
216217
def acorr(
217-
self, x: ArrayLike, *, data=..., **kwargs
218+
self, x: ArrayLike, *, data: DataParamType = ..., **kwargs
218219
) -> tuple[np.ndarray, np.ndarray, LineCollection | Line2D, Line2D | None]: ...
219220
def xcorr(
220221
self,
@@ -225,7 +226,7 @@ class Axes(_AxesBase):
225226
detrend: Callable[[ArrayLike], ArrayLike] = ...,
226227
usevlines: bool = ...,
227228
maxlags: int = ...,
228-
data=...,
229+
data: DataParamType = ...,
229230
**kwargs
230231
) -> tuple[np.ndarray, np.ndarray, LineCollection | Line2D, Line2D | None]: ...
231232
def step(
@@ -234,7 +235,7 @@ class Axes(_AxesBase):
234235
y: ArrayLike,
235236
*args,
236237
where: Literal["pre", "post", "mid"] = ...,
237-
data=...,
238+
data: DataParamType = ...,
238239
**kwargs
239240
) -> list[Line2D]: ...
240241
def bar(
@@ -245,7 +246,7 @@ class Axes(_AxesBase):
245246
bottom: float | ArrayLike | None = ...,
246247
*,
247248
align: Literal["center", "edge"] = ...,
248-
data=...,
249+
data: DataParamType = ...,
249250
**kwargs
250251
) -> BarContainer: ...
251252
def barh(
@@ -256,7 +257,7 @@ class Axes(_AxesBase):
256257
left: float | ArrayLike | None = ...,
257258
*,
258259
align: Literal["center", "edge"] = ...,
259-
data=...,
260+
data: DataParamType = ...,
260261
**kwargs
261262
) -> BarContainer: ...
262263
def bar_label(
@@ -275,7 +276,7 @@ class Axes(_AxesBase):
275276
yrange: tuple[float, float],
276277
align: Literal["bottom", "center", "top"] = ...,
277278
*,
278-
data=...,
279+
data: DataParamType = ...,
279280
**kwargs
280281
) -> PolyCollection: ...
281282
def grouped_bar(
@@ -300,7 +301,7 @@ class Axes(_AxesBase):
300301
bottom: float = ...,
301302
label: str | None = ...,
302303
orientation: Literal["vertical", "horizontal"] = ...,
303-
data=...,
304+
data: DataParamType = ...,
304305
) -> StemContainer: ...
305306

306307
# TODO: data kwarg preprocessor?
@@ -327,7 +328,7 @@ class Axes(_AxesBase):
327328
rotatelabels: bool = ...,
328329
normalize: bool = ...,
329330
hatch: str | Sequence[str] | None = ...,
330-
data=...,
331+
data: DataParamType = ...,
331332
) -> PieContainer: ...
332333
def pie_label(
333334
self,
@@ -359,7 +360,7 @@ class Axes(_AxesBase):
359360
xuplims: bool | ArrayLike = ...,
360361
errorevery: int | tuple[int, int] = ...,
361362
capthick: float | None = ...,
362-
data=...,
363+
data: DataParamType = ...,
363364
**kwargs
364365
) -> ErrorbarContainer: ...
365366
def boxplot(
@@ -394,7 +395,7 @@ class Axes(_AxesBase):
394395
zorder: float | None = ...,
395396
capwidths: float | ArrayLike | None = ...,
396397
label: Sequence[str] | None = ...,
397-
data=...,
398+
data: DataParamType = ...,
398399
) -> dict[str, Any]: ...
399400
def bxp(
400401
self,
@@ -439,7 +440,7 @@ class Axes(_AxesBase):
439440
edgecolors: Literal["face", "none"] | ColorType | Sequence[ColorType] | None = ...,
440441
colorizer: Colorizer | None = ...,
441442
plotnonfinite: bool = ...,
442-
data=...,
443+
data: DataParamType = ...,
443444
**kwargs
444445
) -> PathCollection: ...
445446
def hexbin(
@@ -464,7 +465,7 @@ class Axes(_AxesBase):
464465
mincnt: int | None = ...,
465466
marginals: bool = ...,
466467
colorizer: Colorizer | None = ...,
467-
data=...,
468+
data: DataParamType = ...,
468469
**kwargs
469470
) -> PolyCollection: ...
470471
def arrow(
@@ -473,9 +474,9 @@ class Axes(_AxesBase):
473474
def quiverkey(
474475
self, Q: Quiver, X: float, Y: float, U: float, label: str, **kwargs
475476
) -> QuiverKey: ...
476-
def quiver(self, *args, data=..., **kwargs) -> Quiver: ...
477-
def barbs(self, *args, data=..., **kwargs) -> Barbs: ...
478-
def fill(self, *args, data=..., **kwargs) -> list[Polygon]: ...
477+
def quiver(self, *args, data: DataParamType = ..., **kwargs) -> Quiver: ...
478+
def barbs(self, *args, data: DataParamType = ..., **kwargs) -> Barbs: ...
479+
def fill(self, *args, data: DataParamType = ..., **kwargs) -> list[Polygon]: ...
479480
def fill_between(
480481
self,
481482
x: ArrayLike,
@@ -485,7 +486,7 @@ class Axes(_AxesBase):
485486
interpolate: bool = ...,
486487
step: Literal["pre", "post", "mid"] | None = ...,
487488
*,
488-
data=...,
489+
data: DataParamType = ...,
489490
**kwargs
490491
) -> FillBetweenPolyCollection: ...
491492
def fill_betweenx(
@@ -497,7 +498,7 @@ class Axes(_AxesBase):
497498
step: Literal["pre", "post", "mid"] | None = ...,
498499
interpolate: bool = ...,
499500
*,
500-
data=...,
501+
data: DataParamType = ...,
501502
**kwargs
502503
) -> FillBetweenPolyCollection: ...
503504
def imshow(
@@ -519,7 +520,7 @@ class Axes(_AxesBase):
519520
filterrad: float = ...,
520521
resample: bool | None = ...,
521522
url: str | None = ...,
522-
data=...,
523+
data: DataParamType = ...,
523524
**kwargs
524525
) -> AxesImage: ...
525526
def pcolor(
@@ -532,7 +533,7 @@ class Axes(_AxesBase):
532533
vmin: float | None = ...,
533534
vmax: float | None = ...,
534535
colorizer: Colorizer | None = ...,
535-
data=...,
536+
data: DataParamType = ...,
536537
**kwargs
537538
) -> Collection: ...
538539
def pcolormesh(
@@ -546,7 +547,7 @@ class Axes(_AxesBase):
546547
colorizer: Colorizer | None = ...,
547548
shading: Literal["flat", "nearest", "gouraud", "auto"] | None = ...,
548549
antialiased: bool = ...,
549-
data=...,
550+
data: DataParamType = ...,
550551
**kwargs
551552
) -> QuadMesh: ...
552553
def pcolorfast(
@@ -558,11 +559,11 @@ class Axes(_AxesBase):
558559
vmin: float | None = ...,
559560
vmax: float | None = ...,
560561
colorizer: Colorizer | None = ...,
561-
data=...,
562+
data: DataParamType = ...,
562563
**kwargs
563564
) -> AxesImage | PcolorImage | QuadMesh: ...
564-
def contour(self, *args, data=..., **kwargs) -> QuadContourSet: ...
565-
def contourf(self, *args, data=..., **kwargs) -> QuadContourSet: ...
565+
def contour(self, *args, data: DataParamType = ..., **kwargs) -> QuadContourSet: ...
566+
def contourf(self, *args, data: DataParamType = ..., **kwargs) -> QuadContourSet: ...
566567
def clabel(
567568
self, CS: ContourSet, levels: ArrayLike | None = ..., **kwargs
568569
) -> list[Text]: ...
@@ -584,7 +585,7 @@ class Axes(_AxesBase):
584585
color: ColorType | Sequence[ColorType] | None = ...,
585586
label: str | Sequence[str] | None = ...,
586587
stacked: bool = ...,
587-
data=...,
588+
data: DataParamType = ...,
588589
**kwargs
589590
) -> tuple[
590591
np.ndarray | list[np.ndarray],
@@ -599,7 +600,7 @@ class Axes(_AxesBase):
599600
orientation: Literal["vertical", "horizontal"] = ...,
600601
baseline: float | ArrayLike | None = ...,
601602
fill: bool = ...,
602-
data=...,
603+
data: DataParamType = ...,
603604
**kwargs
604605
) -> StepPatch: ...
605606
def hist2d(
@@ -617,7 +618,7 @@ class Axes(_AxesBase):
617618
weights: ArrayLike | None = ...,
618619
cmin: float | None = ...,
619620
cmax: float | None = ...,
620-
data=...,
621+
data: DataParamType = ...,
621622
**kwargs
622623
) -> tuple[np.ndarray, np.ndarray, np.ndarray, QuadMesh]: ...
623624
def ecdf(
@@ -628,7 +629,7 @@ class Axes(_AxesBase):
628629
complementary: bool=...,
629630
orientation: Literal["vertical", "horizontal"]=...,
630631
compress: bool=...,
631-
data=...,
632+
data: DataParamType = ...,
632633
**kwargs
633634
) -> Line2D: ...
634635
def psd(
@@ -647,7 +648,7 @@ class Axes(_AxesBase):
647648
sides: Literal["default", "onesided", "twosided"] | None = ...,
648649
scale_by_freq: bool | None = ...,
649650
return_line: bool | None = ...,
650-
data=...,
651+
data: DataParamType = ...,
651652
**kwargs
652653
) -> tuple[np.ndarray, np.ndarray] | tuple[np.ndarray, np.ndarray, Line2D]: ...
653654
def csd(
@@ -667,7 +668,7 @@ class Axes(_AxesBase):
667668
sides: Literal["default", "onesided", "twosided"] | None = ...,
668669
scale_by_freq: bool | None = ...,
669670
return_line: bool | None = ...,
670-
data=...,
671+
data: DataParamType = ...,
671672
**kwargs
672673
) -> tuple[np.ndarray, np.ndarray] | tuple[np.ndarray, np.ndarray, Line2D]: ...
673674
def magnitude_spectrum(
@@ -680,7 +681,7 @@ class Axes(_AxesBase):
680681
pad_to: int | None = ...,
681682
sides: Literal["default", "onesided", "twosided"] | None = ...,
682683
scale: Literal["default", "linear", "dB"] | None = ...,
683-
data=...,
684+
data: DataParamType = ...,
684685
**kwargs
685686
) -> tuple[np.ndarray, np.ndarray, Line2D]: ...
686687
def angle_spectrum(
@@ -692,7 +693,7 @@ class Axes(_AxesBase):
692693
window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = ...,
693694
pad_to: int | None = ...,
694695
sides: Literal["default", "onesided", "twosided"] | None = ...,
695-
data=...,
696+
data: DataParamType = ...,
696697
**kwargs
697698
) -> tuple[np.ndarray, np.ndarray, Line2D]: ...
698699
def phase_spectrum(
@@ -704,7 +705,7 @@ class Axes(_AxesBase):
704705
window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = ...,
705706
pad_to: int | None = ...,
706707
sides: Literal["default", "onesided", "twosided"] | None = ...,
707-
data=...,
708+
data: DataParamType = ...,
708709
**kwargs
709710
) -> tuple[np.ndarray, np.ndarray, Line2D]: ...
710711
def cohere(
@@ -722,7 +723,7 @@ class Axes(_AxesBase):
722723
pad_to: int | None = ...,
723724
sides: Literal["default", "onesided", "twosided"] = ...,
724725
scale_by_freq: bool | None = ...,
725-
data=...,
726+
data: DataParamType = ...,
726727
**kwargs
727728
) -> tuple[np.ndarray, np.ndarray]: ...
728729
def specgram(
@@ -746,7 +747,7 @@ class Axes(_AxesBase):
746747
scale: Literal["default", "linear", "dB"] | None = ...,
747748
vmin: float | None = ...,
748749
vmax: float | None = ...,
749-
data=...,
750+
data: DataParamType = ...,
750751
**kwargs
751752
) -> tuple[np.ndarray, np.ndarray, np.ndarray, AxesImage]: ...
752753
def spy(
@@ -781,7 +782,7 @@ class Axes(_AxesBase):
781782
side: Literal["both", "low", "high"] = ...,
782783
facecolor: Sequence[ColorType] | ColorType | None = ...,
783784
linecolor: Sequence[ColorType] | ColorType | None = ...,
784-
data=...,
785+
data: DataParamType = ...,
785786
) -> dict[str, Collection]: ...
786787
def violin(
787788
self,

0 commit comments

Comments
 (0)