Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 26e5801 + 80d0ac8 commit d15be69Copy full SHA for d15be69
lib/matplotlib/category.py
@@ -138,7 +138,12 @@ def __init__(self, units_mapping):
138
self._units = units_mapping
139
140
def __call__(self, x, pos=None):
141
- return '' if pos is None else self.format_ticks([x])[0]
+ """
142
+ Return the category label string for tick val *x*.
143
+
144
+ The position *pos* is ignored.
145
146
+ return self.format_ticks([x])[0]
147
148
def format_ticks(self, values):
149
r_mapping = {v: self._text(k) for k, v in self._units.items()}
lib/matplotlib/tests/test_category.py
@@ -156,16 +156,16 @@ def test_StrCategoryFormatter(self, ax, ydata):
156
unit = cat.UnitData(ydata)
157
labels = cat.StrCategoryFormatter(unit._mapping)
158
for i, d in enumerate(ydata):
159
- assert labels(i, i) == _to_str(d)
+ assert labels(i, i) == d
160
+ assert labels(i, None) == d
161
162
@pytest.mark.parametrize("ydata", cases, ids=ids)
163
@pytest.mark.parametrize("plotter", PLOT_LIST, ids=PLOT_IDS)
164
def test_StrCategoryFormatterPlot(self, ax, ydata, plotter):
165
plotter(ax, range(len(ydata)), ydata)
166
- assert ax.yaxis.major.formatter(i, i) == _to_str(d)
167
- assert ax.yaxis.major.formatter(i+1, i+1) == ""
168
- assert ax.yaxis.major.formatter(0, None) == ""
+ assert ax.yaxis.major.formatter(i) == d
+ assert ax.yaxis.major.formatter(i+1) == ""
169
170
171
def axis_test(axis, labels):
0 commit comments