@@ -359,9 +359,8 @@ def default_crs(self, func, *args, crs=None, **kwargs):
359359
360360def _axis_labels_title (data , axis = None , units = True ):
361361 """
362- Get data and label for pandas or xarray objects or their coordinates
363- along axis `axis`. If `units` is ``True`` also look for units on xarray
364- data arrays.
362+ Get data and label for pandas or xarray objects or their coordinates along axis
363+ `axis`. If `units` is ``True`` also look for units on xarray data arrays.
365364 """
366365 label = ''
367366 _load_objects ()
@@ -386,12 +385,14 @@ def _axis_labels_title(data, axis=None, units=True):
386385 # Pandas object with name attribute
387386 # if not label and isinstance(data, DataFrame) and data.columns.size == 1:
388387 elif isinstance (data , (DataFrame , Series , Index )):
389- if axis == 0 and isinstance (data , (DataFrame , Series )):
388+ if axis == 0 and isinstance (data , Index ):
389+ pass
390+ elif axis == 0 and isinstance (data , (DataFrame , Series )):
390391 data = data .index
391392 elif axis == 1 and isinstance (data , DataFrame ):
392393 data = data .columns
393- elif axis is not None :
394- data = np .arange ( len ( data )) # e.g. for Index
394+ elif axis == 1 and isinstance ( data , ( Series , Index )) :
395+ data = np .array ([ data . name ]) # treat series name as the "column" data
395396 # DataFrame has no native name attribute but user can add one:
396397 # https://github.com/pandas-dev/pandas/issues/447
397398 label = getattr (data , 'name' , '' ) or ''
0 commit comments