diff --git a/hvplot/plotting/core.py b/hvplot/plotting/core.py index 5eb0b46e6..b9dc5e7e4 100644 --- a/hvplot/plotting/core.py +++ b/hvplot/plotting/core.py @@ -1882,13 +1882,21 @@ def _get_converter(self, x=None, y=None, kind=None, **kwds): for v in params.values() if isinstance(v, (str, list)) ] + columns = ( set(self._data.columns) & set(itertools.chain(*possible_columns)) ) or {self._data.columns[0]} + if y is None: + # When y is not specified HoloViewsConverter finds all the numeric + # columns and use them as y values (see _process_chart_y). We meed + # to include these columns too. + columns |= set(self._data.select(pl.col(pl.NUMERIC_DTYPES)).columns) xs = x if is_list_like(x) else (x,) ys = y if is_list_like(y) else (y,) columns |= {*xs, *ys} columns.discard(None) + # Reorder the columns as in the data. + columns = sorted(columns, key=lambda c: self._data.columns.index(c)) if isinstance(self._data, pl.DataFrame): data = self._data.select(columns).to_pandas() diff --git a/hvplot/tests/testplotting.py b/hvplot/tests/testplotting.py index 7ff44b5c7..ed7be693f 100644 --- a/hvplot/tests/testplotting.py +++ b/hvplot/tests/testplotting.py @@ -68,4 +68,5 @@ def test_plot_supports_polars(): pl = pytest.importorskip("polars") dfp = pl.DataFrame(makeDataFrame()) out = plot(dfp, 'line') - assert isinstance(out, hv.Curve) + assert isinstance(out, hv.NdOverlay) + assert out.keys() == dfp.columns