@@ -674,24 +674,27 @@ def plotmethod(self, *args, **kwargs):
674
674
setattr (_Dataset_PlotMethods , plotmethod .__name__ , plotmethod )
675
675
676
676
677
- def _temp_dataarray (ds , y , kwargs ):
677
+ def _temp_dataarray (ds , y , args , kwargs ):
678
678
"""Create a temporary datarray with extra coords."""
679
679
from ..core .dataarray import DataArray
680
680
681
681
# Base coords:
682
682
coords = dict (ds .coords )
683
683
684
684
# Add extra coords to the DataArray:
685
- coords .update (
686
- {v : ds [v ] for v in kwargs .values () if ds .data_vars .get (v ) is not None }
687
- )
685
+ all_args = args + tuple (kwargs .values ())
686
+ coords .update ({v : ds [v ] for v in all_args if ds .data_vars .get (v ) is not None })
687
+
688
+ # The dataarray has to include all the dims. Broadcast to that shape
689
+ # and add the additional coords:
690
+ _y = ds [y ].broadcast_like (ds )
688
691
689
- return DataArray (ds [ y ] , coords = coords )
692
+ return DataArray (_y , coords = coords )
690
693
691
694
692
695
@_attach_to_plot_class
693
- def line (ds , y = None , ** kwargs ):
696
+ def line (ds , x , y , * args , ** kwargs ):
694
697
"""Line plot Dataset data variables against each other."""
695
- da = _temp_dataarray (ds , y , kwargs )
698
+ da = _temp_dataarray (ds , y , args , kwargs )
696
699
697
- return da .plot .line (** kwargs )
700
+ return da .plot .line (x , * args , ** kwargs )
0 commit comments