holoviz / hvplot

A high-level plotting API for pandas, dask, xarray, and networkx built on HoloViews
https://hvplot.holoviz.org
BSD 3-Clause "New" or "Revised" License
1.13k stars 109 forks source link

The visualization rendered depends on the active render at plot creation #1236

Open MarcSkovMadsen opened 10 months ago

MarcSkovMadsen commented 10 months ago

I'm on hvplot==0.9.1, holoviews==1.18.1, trying to communicate to the world that hvPlot now works with Polars.

To my surprice I cannot create and render independently to any of the backends. I must recreate and render the plot.

I believe that it must be a fundamental principle that I can create the plot objects and render independently. Anything else does not make sense in my world. Otherwise I can't reuse a plot for different use cases.

Does not work if I create plot once

image

Works when I create plots again

image

Code

import polars as pl
import hvplot.polars

df = pl.read_csv("Christmas tree sales 2004-2016.csv")
df = df.with_columns(pl.col("total_trees_sold")/10**6)
plot = df.hvplot.bar(x="Year", y="total_trees_sold", title="Christmas Trees sold by year", color="red", ylabel="Trees Sold in millions", height=200, width=1200)

hvplot.extension("bokeh")
plot

hvplot.extension("matplotlib")
plot

hvplot.extension("plotly")
plot

Christmas tree sales 2004-2016.csv

maximlt commented 10 months ago

Indeed this looks like a bug.

maximlt commented 10 months ago

Not that the recommended and documented way to switch between plotting extensions is to load them all upfront and then use hvplot.output(backend=<backend>) to switch.