Open fonnesbeck opened 2 months ago
hey @fonnesbeck
the plotting methods in Polars are shorthand for some Altair ones, e.g.:
df.plot.line(x='x', y='y')
is shorthand for alt.Chart(df).mark_line().encode(x='x', y='y')
df.plot.line(x='x', y='y')
is shorthand for alt.Chart(df).mark_bar().encode(x='x', y='y')
It's not meant to be perfectly backwards-compatible with the hvplot API
If you want to keep your plot working as before, you can add import hvplot.polars
to the top of your script, and then do simulated_df.select(pl.col("shotRebound")).plot.hist(bins=30, title="Histogram of Shot Rebounds", xlabel="Shot Rebound", ylabel="Frequency")
will post an Altair solution soon
Altair solution (requires an explicit import altair as alt
- though I'd suggest trying df['shotRebound'].hist()
in case the default is good enough)
import altair as alt
simulated_df.plot.bar(
x=alt.X("shotRebound", bin=alt.Bin(maxbins=30), title="Shot Rebound"),
y=alt.Y("count()", title="Frequency"),
).properties(title="Histogram of Shot Rebounds", width=600)
this may be common enough that max_bins
could be added to Series.hist
🤔
Yikes, that's pretty verbose for a simple histogram!
yup - some substantial improvements are on their way, just give it another week or so
Checks
Reproducible example
Log output
Issue description
Despite up-to-date versions of polars and altair being installed, plotting a histogram fails, apparently due to incompatibility between the two libraries.
Expected behavior
Plotted histogram
Installed versions