5
5
import numpy as np
6
6
7
7
8
- from ..core .utils import peek_at
9
8
from ..core .formatting import format_item
10
9
from .utils import (
11
10
_infer_xy_labels ,
@@ -401,8 +400,12 @@ def map_groupby(
401
400
func_kwargs .update ({"add_colorbar" : False , "add_labels" : False })
402
401
403
402
# Get x, y labels for the first subplot
403
+ grouped = self .data
404
+ first_group = grouped ._obj .isel (
405
+ ** {grouped ._group_dim : grouped ._group_indices [0 ]}
406
+ ).squeeze ()
404
407
x , y = _infer_xy_labels (
405
- darray = peek_at ( self . data . _iter_grouped ())[ 0 ] ,
408
+ darray = first_group ,
406
409
x = x ,
407
410
y = y ,
408
411
imshow = func .__name__ == "imshow" ,
@@ -425,9 +428,17 @@ def map_groupby_line(
425
428
):
426
429
from .plot import _infer_line_data
427
430
431
+ grouped = self .data
432
+ first_group = grouped ._obj .isel (
433
+ ** {grouped ._group_dim : grouped ._group_indices [0 ]}
434
+ ).squeeze ()
435
+ _ , _ , hueplt , xlabel , ylabel , huelabel = _infer_line_data (
436
+ darray = first_group , x = x , y = y , hue = hue
437
+ )
438
+
428
439
for (_ , subset ), ax in zip (self .data , self .axes .flat ):
429
440
mappable = func (
430
- subset ,
441
+ subset . squeeze () ,
431
442
x = x ,
432
443
y = y ,
433
444
ax = ax ,
@@ -438,10 +449,6 @@ def map_groupby_line(
438
449
)
439
450
self ._mappables .append (mappable )
440
451
441
- _ , _ , hueplt , xlabel , ylabel , huelabel = _infer_line_data (
442
- darray = peek_at (self .data ._iter_grouped ())[0 ], x = x , y = y , hue = hue
443
- )
444
-
445
452
self ._hue_var = hueplt
446
453
self ._hue_label = huelabel
447
454
self ._finalize_grid (xlabel , ylabel )
0 commit comments