@@ -177,11 +177,8 @@ def line(darray, *args, **kwargs):
177
177
hue : string, optional
178
178
Coordinate for which you want multiple lines plotted
179
179
(2D DataArrays only).
180
- x : string, optional
181
- 1D and 2D DataArrays: Coordinate for x axis.
182
- y : string, optional
183
- 1D DataArray: Can be coordinate name or DataArray.name
184
- 2D DataArray: Coordinate for y axis.
180
+ x, y : string, optional
181
+ Coordinates for x, y axis. Only one of these may be specified.
185
182
add_legend : boolean, optional
186
183
Add legend with y axis coordinates (2D inputs only).
187
184
*args, **kwargs : optional
@@ -207,29 +204,27 @@ def line(darray, *args, **kwargs):
207
204
208
205
ax = get_axis (figsize , size , aspect , ax )
209
206
210
- if ndims == 1 :
211
- dim , = darray .dims # get the only dimension name
207
+ error_msg = 'must be either None or %r' % (' or ' .join (darray .dims ))
212
208
213
- error_msg = 'must be either None or %r' % dim
214
- if darray .name :
215
- error_msg += ' or %r.' % darray .name
209
+ if x not in [None , * darray .dims ]:
210
+ raise ValueError ('x ' + error_msg )
216
211
217
- if x not in [None , dim , darray .name ]:
218
- raise ValueError ('x ' + error_msg )
212
+ if y not in [None , * darray .dims ]:
213
+ raise ValueError ('y ' + error_msg )
219
214
220
- if y not in [ None , dim , darray . name ] :
221
- raise ValueError ('y ' + error_msg )
215
+ if x is not None and y is not None :
216
+ raise ValueError ('You cannot specify both x and y kwargs.' )
222
217
223
- if x is not None and y is not None and x == y :
224
- raise ValueError ( 'Cannot make a plot with x=%r and y=%r' % ( x , y ))
218
+ if ndims == 1 :
219
+ dim , = darray . dims # get the only dimension name
225
220
226
- if (x is None and y is None ) or x == dim or y == darray . name :
221
+ if (x is None and y is None ) or x == dim :
227
222
xplt = darray .coords [dim ]
228
223
yplt = darray
229
224
xlabel = dim
230
225
ylabel = darray .name
231
226
232
- elif y == dim or x == darray . name :
227
+ else :
233
228
yplt = darray .coords [dim ]
234
229
xplt = darray
235
230
xlabel = darray .name
@@ -246,10 +241,6 @@ def line(darray, *args, **kwargs):
246
241
yplt = darray .transpose (xlabel , huelabel )
247
242
248
243
else :
249
- if x is not None and x is not darray .name :
250
- raise ValueError ('Cannot make a plot with x=%r and y=%r '
251
- % (x , y ))
252
-
253
244
ylabel , huelabel = _infer_xy_labels (darray = darray , x = y , y = hue )
254
245
xlabel = darray .name
255
246
xplt = darray .transpose (ylabel , huelabel )
0 commit comments