Save interactive html plot with Plots.jl

I produced a plot with Plots.jl and plotly backend. In jupyter notebook, this plot has basic interactivity like zooming and tooltips. I would like to save it to say HTML so that this basic interactivity is preserved. I tried

using Plots
plotly()
plt = plot(randn(100))
Plots.html(plt, "hello")

but when I open “hello.html” in the browser I see just an empty page.

1 Like

As an alternative, the following allows to save a plot that is zoomable:

using WGLMakie
scene = lines(randn(10))
WGLMakie.save("hello.html", scene)

How about savefig("hello.html")

1 Like

Fyi, the saved html zooms fine, running Julia 1.7 on Win10, PlotlyBase v0.8.18, Plots v1.22.3.

1 Like

Interesting. It turns out that Plots.html works for me if I run it in the repl. If I run it in jupyter instaed, the resulting file is broken (show an empty webpage).

2 Likes

Thanks. It works in the repl, but fails in jupyter notebook for me.

Just in case, have you also tried using the plotlyjs() backend?

I also tried it, it also produces broken HTML, when I run it in jupyter.

Possibly not the real thing but FWIW, tested in the Jupyter extension for VS Code your initial plotly() example and it saved a proper html that could be zoomed.

1 Like