Why won't `savefig` work with `plotly`?

I have a program that runs without any problems. When I try to use the Plotly as a backend it generates an error (see at the bottom of this post).

I can see 'Plotly and 'PlotlyBase in Project.toml.

The command that causes the error is:

savefig(p, plot_save_path)

Here plot_save_path is a valid path. The command only generates an error if the following is executed before it:

plotly()

The error message is:

plotly()
Plots.savefig(p, plot_save_path)
ERROR: LoadError: UndefVarError: savefig not defined
Stacktrace:
 [1] _show(io::IOStream, #unused#::MIME{Symbol("image/svg+xml")}, plt::Plots.Plot{Plots.PlotlyBackend})
   @ Plots C:\Users\fsald\.julia\packages\Plots\8ouqB\src\backends\plotlybase.jl:21
 [2] show
   @ C:\Users\fsald\.julia\packages\Plots\8ouqB\src\output.jl:214 [inlined]
 [3] svg(plt::Plots.Plot{Plots.PlotlyBackend}, fn::String)
   @ Plots C:\Users\fsald\.julia\packages\Plots\8ouqB\src\output.jl:15        
 [4] savefig(plt::Plots.Plot{Plots.PlotlyBackend}, fn::String)
   @ Plots C:\Users\fsald\.julia\packages\Plots\8ouqB\src\output.jl:123       
 [5] save_plot(p::Plots.Plot{Plots.PlotlyBackend}, filename::String, output_file_path::String; timetag::Bool)
   @ Main C:\Users\fsald\Dropbox\Code\Julia\bootstrapWalkforward\BW1\src\Utils.jl:3148
 [6] save_plot(p::Plots.Plot{Plots.PlotlyBackend}, filename::String, output_file_path::String)
   @ Main C:\Users\fsald\Dropbox\Code\Julia\bootstrapWalkforward\BW1\src\Utils.jl:3136
 [7] optimize(data::DataFrame, ctrl_parms::ControlParameters, params::Vector{Dict{String, Any}}, indx::UnitRange{Int64}; fast::Bool)
   @ Main C:\Users\fsald\Dropbox\Code\Julia\bootstrapWalkforward\BW1\src\ModelFunctions.jl:1329
 [8] top-level scope
   @ c:\Users\fsald\Dropbox\Code\Julia\bootstrapwalkforward\BW1\src\BootWalk.jl:420
in expression starting at c:\Users\fsald\Dropbox\Code\Julia\bootstrapwalkforward\BW1\src\BootWalk.jl:416

How can I save charts while using Plotly as a backend?

1 Like