Skip to content

Commit bb78c01

Browse files
kjaintacaswell
authored andcommitted
Fix the error- TypeError: 'float' object is not iterable (matplotlib#22710)
Co-authored-by: Thomas A Caswell <tcaswell@gmail.com>
1 parent 333deb1 commit bb78c01

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎lib/matplotlib/axis.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,8 +1825,11 @@ def set_ticklabels(self, ticklabels, *, minor=False, **kwargs):
18251825
For each tick, includes ``tick.label1`` if it is visible, then
18261826
``tick.label2`` if it is visible, in that order.
18271827
"""
1828-
ticklabels = [t.get_text() if hasattr(t, 'get_text') else t
1829-
for t in ticklabels]
1828+
try:
1829+
ticklabels = [t.get_text() if hasattr(t, 'get_text') else t
1830+
for t in ticklabels]
1831+
except TypeError:
1832+
raise TypeError(f"{ticklabels:=} must be a sequence") from None
18301833
locator = (self.get_minor_locator() if minor
18311834
else self.get_major_locator())
18321835
if isinstance(locator, mticker.FixedLocator):

0 commit comments

Comments
 (0)