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

Ignore pos in StrCategoryFormatter.__call__ to display correct label in the preview window#16006

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
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
7 changes: 6 additions & 1 deletionlib/matplotlib/category.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -138,7 +138,12 @@ def __init__(self, units_mapping):
self._units = units_mapping

def __call__(self, x, pos=None):
return '' if pos is None else self.format_ticks([x])[0]
"""
Return the category label string for tick val *x*.

The position *pos* is ignored.
"""
return self.format_ticks([x])[0]

def format_ticks(self, values):
r_mapping = {v: self._text(k) for k, v in self._units.items()}
Expand Down
6 changes: 3 additions & 3 deletionslib/matplotlib/tests/test_category.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,15 +154,15 @@ def test_StrCategoryFormatter(self, ax, ydata):
labels = cat.StrCategoryFormatter(unit._mapping)
for i, d in enumerate(ydata):
assert labels(i, i) == d
assert labels(i, None) == d

@pytest.mark.parametrize("ydata", cases, ids=ids)
@pytest.mark.parametrize("plotter", PLOT_LIST, ids=PLOT_IDS)
def test_StrCategoryFormatterPlot(self, ax, ydata, plotter):
plotter(ax, range(len(ydata)), ydata)
for i, d in enumerate(ydata):
assert ax.yaxis.major.formatter(i, i) == d
assert ax.yaxis.major.formatter(i+1, i+1) == ""
assert ax.yaxis.major.formatter(0, None) == ""
assert ax.yaxis.major.formatter(i) == d
assert ax.yaxis.major.formatter(i+1) == ""
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a test thatax.yaxis.major.formatter(i, None) givesd as the label? (which it wouldn't do before this fix)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Thanks, I have updated the test.



def axis_test(axis, labels):
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp