Open
Description
I was wondering, since narwhals was such a success in the plotly express api, whether the graph_objects api could get the same treatment. For the few trace types I tried (Scatter, Bar), arguments such as x, y, marker_color etc., accept tuple, list, numpy array, or pandas Series.
It would be great to be able to pass arrow or polars series as well, via narwhals, though I have no idea how feasible that would really be.
Desired outcome would be something like this:
"""
Fresh environment
>>> uv init
>>> uv add plotly polars
"""
import plotly.graph_objects as go
import polars as pl
df = pl.DataFrame({"x": [0, 1, 2, 3, 4], "y": [0, 1, 4, 9, 16]})
fig = go.Figure()
fig.add_trace(
go.Scatter(x=df["x"], y=df["y"]),
)
fig.show()
Currently one has to either transform to a list, pandas series, or if numpy is installed, there is some implicit transformation, which allows to pass polars series directly.