Skip to content

Commit f330831

Browse files
committed
use index.inferred_type for string test
1 parent 7f88d82 commit f330831

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pandas/plotting/_core.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -561,20 +561,22 @@ def _get_xticks(self, convert_period=False):
561561
if convert_period and isinstance(index, PeriodIndex):
562562
self.data = self.data.reindex(index=index.sort_values())
563563
x = self.data.index.to_timestamp()._mpl_repr()
564-
elif index.is_numeric():
564+
elif (index.is_numeric() or
565+
index.inferred_type in ['string', 'unicode']
566+
):
565567
"""
566568
Matplotlib supports numeric values or datetime objects as
567569
xaxis values. Taking LBYL approach here, by the time
568570
matplotlib raises exception when using non numeric/datetime
569571
values for xaxis, several actions are already taken by plt.
572+
573+
Matplotlib also supports strings as xaxis values.
570574
"""
571575
x = index._mpl_repr()
572576
elif is_datetype:
573577
self.data = self.data[notna(self.data.index)]
574578
self.data = self.data.sort_index()
575579
x = self.data.index._mpl_repr()
576-
elif all(isinstance(val, string_types) for val in index):
577-
x = index._mpl_repr()
578580
else:
579581
self._need_to_set_index = True
580582
x = lrange(len(index))

0 commit comments

Comments
 (0)