@@ -672,16 +672,22 @@ def newplotfunc(
672
672
673
673
# check if we need to broadcast one dimension
674
674
if xval .ndim < yval .ndim :
675
+ dims = darray [ylab ].dims
675
676
if xval .shape [0 ] == yval .shape [0 ]:
676
677
xval = np .broadcast_to (xval [:, np .newaxis ], yval .shape )
677
678
else :
678
679
xval = np .broadcast_to (xval [np .newaxis , :], yval .shape )
679
680
680
681
elif yval .ndim < xval .ndim :
682
+ dims = darray [xlab ].dims
681
683
if yval .shape [0 ] == xval .shape [0 ]:
682
684
yval = np .broadcast_to (yval [:, np .newaxis ], xval .shape )
683
685
else :
684
686
yval = np .broadcast_to (yval [np .newaxis , :], xval .shape )
687
+ elif xval .ndim == 2 :
688
+ dims = darray [xlab ].dims
689
+ else :
690
+ dims = (darray [ylab ].dims [0 ], darray [xlab ].dims [0 ])
685
691
686
692
# May need to transpose for correct x, y labels
687
693
# xlab may be the name of a coord, we have to check for dim names
@@ -691,10 +697,9 @@ def newplotfunc(
691
697
# we transpose to (y, x, color) to make this work.
692
698
yx_dims = (ylab , xlab )
693
699
dims = yx_dims + tuple (d for d in darray .dims if d not in yx_dims )
694
- if dims != darray .dims :
695
- darray = darray .transpose (* dims , transpose_coords = True )
696
- elif darray [xlab ].dims [- 1 ] == darray .dims [0 ]:
697
- darray = darray .transpose (transpose_coords = True )
700
+
701
+ if dims != darray .dims :
702
+ darray = darray .transpose (* dims , transpose_coords = True )
698
703
699
704
# Pass the data as a masked ndarray too
700
705
zval = darray .to_masked_array (copy = False )
0 commit comments