# Save interactive html plot with Plots.jl

**URL:** <https://discourse.julialang.org/t/save-interactive-html-plot-with-plots-jl/68933>\
**Category:** General Usage\
**Tags:** jupyter, plotting, plots, html, plotlyjs\
**Created:** [September 29, 2021, 1:36pm UTC](https://discourse.julialang.org/t/save-interactive-html-plot-with-plots-jl/68933 "2021-09-29T13:36:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [September 29, 2021, 1:36pm UTC](https://discourse.julialang.org/t/save-interactive-html-plot-with-plots-jl/68933/1 "2021-09-29T13:36:27Z")

</div>

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

```julia
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.

---

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [September 29, 2021, 1:45pm UTC](https://discourse.julialang.org/t/save-interactive-html-plot-with-plots-jl/68933/2 "2021-09-29T13:45:39Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [September 29, 2021, 2:24pm UTC](https://discourse.julialang.org/t/save-interactive-html-plot-with-plots-jl/68933/3 "2021-09-29T14:24:45Z")

</div>

How about `savefig("hello.html")`

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [September 29, 2021, 2:38pm UTC](https://discourse.julialang.org/t/save-interactive-html-plot-with-plots-jl/68933/4 "2021-09-29T14:38:30Z")

</div>

> [@jw3126](#):
>
> ```julia
> using Plots; plotly()
> plt = plot(randn(100))
> Plots.html(plt, "hello2")
> 
> ```

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

---

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [September 29, 2021, 3:12pm UTC](https://discourse.julialang.org/t/save-interactive-html-plot-with-plots-jl/68933/5 "2021-09-29T15:12:06Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [September 29, 2021, 3:14pm UTC](https://discourse.julialang.org/t/save-interactive-html-plot-with-plots-jl/68933/6 "2021-09-29T15:14:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [September 29, 2021, 3:29pm UTC](https://discourse.julialang.org/t/save-interactive-html-plot-with-plots-jl/68933/7 "2021-09-29T15:29:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [September 29, 2021, 3:33pm UTC](https://discourse.julialang.org/t/save-interactive-html-plot-with-plots-jl/68933/8 "2021-09-29T15:33:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [September 29, 2021, 3:41pm UTC](https://discourse.julialang.org/t/save-interactive-html-plot-with-plots-jl/68933/9 "2021-09-29T15:41:37Z")

</div>

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.
