@@ -359,9 +359,8 @@ def default_crs(self, func, *args, crs=None, **kwargs):
359
359
360
360
def _axis_labels_title (data , axis = None , units = True ):
361
361
"""
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.
365
364
"""
366
365
label = ''
367
366
_load_objects ()
@@ -386,12 +385,14 @@ def _axis_labels_title(data, axis=None, units=True):
386
385
# Pandas object with name attribute
387
386
# if not label and isinstance(data, DataFrame) and data.columns.size == 1:
388
387
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 )):
390
391
data = data .index
391
392
elif axis == 1 and isinstance (data , DataFrame ):
392
393
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
395
396
# DataFrame has no native name attribute but user can add one:
396
397
# https://github.com/pandas-dev/pandas/issues/447
397
398
label = getattr (data , 'name' , '' ) or ''
0 commit comments