@@ -515,12 +515,11 @@ def _meta_coords(*args, which='x', **kwargs):
515515 Return the index arrays associated with string coordinates and
516516 keyword arguments updated with index locators and formatters.
517517 """
518- # NOTE: Why FixedLocator and not IndexLocator? The latter requires plotting
519- # lines or else an error is raised... very strange .
518+ # NOTE: Why FixedLocator and not IndexLocator? The ticks chosen by the latter
519+ # depend on other plotted content .
520520 # NOTE: Why IndexFormatter and not FixedFormatter? The former ensures labels
521521 # correspond to indices while the latter can mysteriously truncate labels.
522- from matplotlib .ticker import NullLocator
523- from ..ticker import IndexLocator , IndexFormatter
522+ from ..constuctor import Locator , Formatter
524523 res = []
525524 for data in args :
526525 data = _to_duck_array (data )
@@ -529,12 +528,12 @@ def _meta_coords(*args, which='x', **kwargs):
529528 continue
530529 if data .ndim > 1 :
531530 raise ValueError ('Non-1D string coordinate input is unsupported.' )
532- idx = np .arange (len (data ))
533- data = list (map (str , data )) # ensure all are strings
534- kwargs .setdefault (which + 'locator' , IndexLocator ( 1 , 0 ))
535- kwargs .setdefault (which + 'formatter' , IndexFormatter ( data ))
536- kwargs .setdefault (which + 'minorlocator' , NullLocator ( ))
537- res .append (idx )
531+ ticks = np .arange (len (data ))
532+ labels = list (map (str , data ))
533+ kwargs .setdefault (which + 'locator' , Locator ( ticks , index = False ))
534+ kwargs .setdefault (which + 'formatter' , Formatter ( labels , index = True ))
535+ kwargs .setdefault (which + 'minorlocator' , Locator ( 'null' ))
536+ res .append (ticks ) # use these as data coordinates
538537 return (* res , kwargs )
539538
540539
0 commit comments