File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -561,20 +561,22 @@ def _get_xticks(self, convert_period=False):
561
561
if convert_period and isinstance (index , PeriodIndex ):
562
562
self .data = self .data .reindex (index = index .sort_values ())
563
563
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
+ ):
565
567
"""
566
568
Matplotlib supports numeric values or datetime objects as
567
569
xaxis values. Taking LBYL approach here, by the time
568
570
matplotlib raises exception when using non numeric/datetime
569
571
values for xaxis, several actions are already taken by plt.
572
+
573
+ Matplotlib also supports strings as xaxis values.
570
574
"""
571
575
x = index ._mpl_repr ()
572
576
elif is_datetype :
573
577
self .data = self .data [notna (self .data .index )]
574
578
self .data = self .data .sort_index ()
575
579
x = self .data .index ._mpl_repr ()
576
- elif all (isinstance (val , string_types ) for val in index ):
577
- x = index ._mpl_repr ()
578
580
else :
579
581
self ._need_to_set_index = True
580
582
x = lrange (len (index ))
You can’t perform that action at this time.
0 commit comments