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]: Incomplete annotation forlabels inAxes.set_xticklabels #27297

Closed as not planned
@pawjast

Description

@pawjast

Documentation Link

https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.set_xticklabels.html

Problem

The explanation forlabels says it accepts either sequence of strings or Texts:

image

However, it's also possible to pass as a parameter e.g.list ofints orfloats or similar and the method works too.

I think this should be reflected in the doc.

importrandomimportmatplotlib.pyplotaspltx=sorted(random.sample(range(15),5))y=sorted(random.sample(range(10),5))fig,ax=plt.subplots(figsize=(10,6))ax.plot(x,y,"o-")ax.set_xticks(x)ax.set_xticklabels(x)# x is `list` of INTs, not stringsax.grid(axis="x")

Gives this, without any problems:

image

Or if you generate list of floats:

x_labels= [random.random()for_inrange(len(x))]

And then update the tick labels:

ax.set_xticklabels(x_labels)# x is `list` of FLOATs, not strings

I'll get this:
image

Suggested improvement

Update the description so it's clear numeric arrays can be passed on as a parameter.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp