Skip to content

[DOC/TYP]: Allow any array like for set_[xy]ticks, not just list of float #25798

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions lib/matplotlib/axes/_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ class _AxesBase(martist.Artist):
def get_xticks(self, *, minor: bool = ...) -> np.ndarray: ...
def set_xticks(
self,
ticks: Iterable[float],
ticks: ArrayLike,
labels: Iterable[str] | None = ...,
*,
minor: bool = ...,
Expand All @@ -424,7 +424,7 @@ class _AxesBase(martist.Artist):
def get_yticks(self, *, minor: bool = ...) -> np.ndarray: ...
def set_yticks(
self,
ticks: Iterable[float],
ticks: ArrayLike,
labels: Iterable[str] | None = ...,
*,
minor: bool = ...,
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_secondary_axes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SecondaryAxis(_AxesBase):
) -> None: ...
def set_ticks(
self,
ticks: Iterable[float],
ticks: ArrayLike,
labels: Iterable[str] | None = ...,
*,
minor: bool = ...,
Expand Down
6 changes: 4 additions & 2 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2009,10 +2009,12 @@ def set_ticks(self, ticks, labels=None, *, minor=False, **kwargs):

Parameters
----------
ticks : list of floats
List of tick locations. The axis `.Locator` is replaced by a
ticks : 1D ArrayLike
Array of tick locations. The axis `.Locator` is replaced by a
`~.ticker.FixedLocator`.

The values may be either floats or in axis units.

Some tick formatters will not label arbitrary tick positions;
e.g. log formatters only label decade ticks by default. In
such a case you can set a formatter explicitly on the axis
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/axis.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class Axis(martist.Artist):
) -> list[Text]: ...
def set_ticks(
self,
ticks: Iterable[float],
ticks: ArrayLike,
labels: Iterable[str] | None = ...,
*,
minor: bool = ...,
Expand Down
3 changes: 2 additions & 1 deletion lib/matplotlib/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ class Colorbar:
drawedges : bool
Whether to draw lines at color boundaries.


%(_colormap_kw_doc)s

location : None or {'left', 'right', 'top', 'bottom'}
Expand Down Expand Up @@ -863,7 +864,7 @@ def set_ticks(self, ticks, *, labels=None, minor=False, **kwargs):

Parameters
----------
ticks : list of floats
ticks : 1D array-like
List of tick locations.
labels : list of str, optional
List of tick labels. If not set, the labels show the data value.
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,7 @@ def ylim(*args, **kwargs) -> tuple[float, float]:


def xticks(
ticks: Sequence[float] | None = None,
ticks: ArrayLike | None = None,
labels: Sequence[str] | None = None,
*,
minor: bool = False,
Expand Down Expand Up @@ -1963,7 +1963,7 @@ def xticks(


def yticks(
ticks: Sequence[float] | None = None,
ticks: ArrayLike | None = None,
labels: Sequence[str] | None = None,
*,
minor: bool = False,
Expand Down