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

Commit80d0ac8

Browse files
anntzertacaswell
authored andcommitted
Backport PR#16006: Ignore pos in StrCategoryFormatter.__call__ to display correct label in the preview window
Ignore pos in StrCategoryFormatter.__call__ to display correct… (#16006)Ignore pos in StrCategoryFormatter.__call__ to display correct label in the preview windowConflicts:lib/matplotlib/tests/test_category.py - collision with py2 removal work (_to_str)
1 parent0900819 commit80d0ac8

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

‎lib/matplotlib/category.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,12 @@ def __init__(self, units_mapping):
138138
self._units=units_mapping
139139

140140
def__call__(self,x,pos=None):
141-
return''ifposisNoneelseself.format_ticks([x])[0]
141+
"""
142+
Return the category label string for tick val *x*.
143+
144+
The position *pos* is ignored.
145+
"""
146+
returnself.format_ticks([x])[0]
142147

143148
defformat_ticks(self,values):
144149
r_mapping= {v:self._text(k)fork,vinself._units.items()}

‎lib/matplotlib/tests/test_category.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,16 @@ def test_StrCategoryFormatter(self, ax, ydata):
156156
unit=cat.UnitData(ydata)
157157
labels=cat.StrCategoryFormatter(unit._mapping)
158158
fori,dinenumerate(ydata):
159-
assertlabels(i,i)==_to_str(d)
159+
assertlabels(i,i)==d
160+
assertlabels(i,None)==d
160161

161162
@pytest.mark.parametrize("ydata",cases,ids=ids)
162163
@pytest.mark.parametrize("plotter",PLOT_LIST,ids=PLOT_IDS)
163164
deftest_StrCategoryFormatterPlot(self,ax,ydata,plotter):
164165
plotter(ax,range(len(ydata)),ydata)
165166
fori,dinenumerate(ydata):
166-
assertax.yaxis.major.formatter(i,i)==_to_str(d)
167-
assertax.yaxis.major.formatter(i+1,i+1)==""
168-
assertax.yaxis.major.formatter(0,None)==""
167+
assertax.yaxis.major.formatter(i)==d
168+
assertax.yaxis.major.formatter(i+1)==""
169169

170170

171171
defaxis_test(axis,labels):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp