-
-
Couldn't load subscription status.
- Fork 78
Closed
Description
Describe the bug
Hi there,
With the current version, savefig does not produce a running HTML file. Here is a MWE:
cd(expanduser("~/Desktop"))
run(`rm -rf Project.toml Manifest.toml`)
using Pkg
Pkg.activate(".")
Pkg.add("Plots")
Pkg.add("PlotlyJS")
using Plots
plotlyjs()
p = plot(randn(10))
savefig(p, "test.html")
The resulting HTML has the following form:
<script src="https://cdn.plot.ly/plotly-2.6.3.min.js"></script> <div id="4c1c9687-32be-43b7-91a4-9d678663744e" style="width:600px;height:400px;"></div>
<script src="https://requirejs.org/docs/release/2.3.7/minified/require.js" onload="plots_jl_plotly_init()"></script>
<script>
function plots_jl_plotly_init() {
Plotly.newPlot('4c1c9687-32be-43b7-91a4-9d678663744e', [
...
</script>
The Web Inspector in Safari throws the error ReferenceError: Can't find variable: plots_jl_plotly_init – and the html also does not work in Firefox. In order to get the figure to work, one has to swap the 2nd and the 3rd <script> statement:
<script src="https://cdn.plot.ly/plotly-2.6.3.min.js"></script> <div id="4c1c9687-32be-43b7-91a4-9d678663744e" style="width:600px;height:400px;"></div>
<script>
function plots_jl_plotly_init() {
Plotly.newPlot('4c1c9687-32be-43b7-91a4-9d678663744e', [
...
</script>
<script src="https://requirejs.org/docs/release/2.3.7/minified/require.js" onload="plots_jl_plotly_init()"></script>
With this modification, plots_jl_plotly_init() is defined before it is loaded.
Version info
Please provide the following:
- output of julia command
versioninfo()
Julia Version 1.11.5
Commit 760b2e5b739 (2025-04-14 06:53 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (x86_64-apple-darwin24.0.0)
CPU: 16 × Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, skylake)
Threads: 8 default, 0 interactive, 4 GC (on 16 virtual cores)
Environment:
JULIA_EDITOR = code
JULIA_VSCODE_REPL = 1
JULIA_NUM_THREADS = 8
- Output running the following in Julia 0.7 or greater:
using Pkg; pkg"status"(if you are on Julia 0.6 or earlier runPkg.status())
Status `~/Desktop/Project.toml`
[f0f68f2c] PlotlyJS v0.18.16
[91a5bcdd] Plots v1.40.14
Many thanks for looking into this!
Metadata
Metadata
Assignees
Labels
No labels