Skip to content

Commit b8f082b

Browse files
committed
Allow binned coords on 1D plots y-axis. See #3571.
1 parent ff75081 commit b8f082b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

xarray/plot/plot.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,12 @@ def line(
297297
xplt, yplt, hueplt, xlabel, ylabel, hue_label = _infer_line_data(darray, x, y, hue)
298298

299299
# Remove pd.Intervals if contained in xplt.values.
300-
if _valid_other_type(xplt.values, [pd.Interval]):
300+
if any(
301+
[
302+
_valid_other_type(xplt.values, [pd.Interval]),
303+
_valid_other_type(yplt.values, [pd.Interval]),
304+
]
305+
):
301306
# Is it a step plot? (see matplotlib.Axes.step)
302307
if kwargs.get("linestyle", "").startswith("steps-"):
303308
xplt_val, yplt_val = _interval_to_double_bound_points(
@@ -313,8 +318,14 @@ def line(
313318
if kwargs["linestyle"] == "":
314319
del kwargs["linestyle"]
315320
else:
316-
xplt_val = _interval_to_mid_points(xplt.values)
317-
yplt_val = yplt.values
321+
if _valid_other_type(xplt.values, [pd.Interval]):
322+
xplt_val = _interval_to_mid_points(xplt.values)
323+
else:
324+
xplt_val = xplt.values
325+
if _valid_other_type(yplt.values, [pd.Interval]):
326+
yplt_val = _interval_to_mid_points(yplt.values)
327+
else:
328+
yplt_val = yplt.values
318329
xlabel += "_center"
319330
else:
320331
xplt_val = xplt.values

0 commit comments

Comments
 (0)