PlotlyJS.jl icon indicating copy to clipboard operation
PlotlyJS.jl copied to clipboard

GenericTrace savefig error

Open jmbyars opened this issue 5 years ago • 1 comments
trafficstars

I am trying to plot a series of boxplot following http://spencerlyon.com/PlotlyJS.jl/examples/box_plots/ and export it to a static file. However, I am getting errors running the following code:

Code

using PlotlyJS
using Blink
using ORCA
using JuliaDB
using JuliaDBMeta

plot_traces = GenericTrace[]
for keys in collect(keys(boxplot_dict))

    boxplot = box(; name                = boxplot_dict[keys]["name"], # Specify trace name
                    y                   = boxplot_dict[keys]["data"], # Specify trace data
                    text                = boxplot_dict[keys]["hover"], # Specify Hovertext data
                    hoverinfo           = "y+text" # Hover data displayed
                    )
    push!(plot_traces, boxplot)
end

plot(plot_traces, style = boxplot_style)
PlotlyJS.savefig(plot_traces, "test.pdf")

However, I keep getting this error regardless of the file format.

Error

ERROR: MethodError: no method matching savefig(::Array{GenericTrace,1}, ::String)
Closest candidates are:
  savefig(::Plot, ::AbstractString; format, scale, width, height) at /home/jmb/.julia/packages/ORCA/xULYl/src/ORCA.jl:66
  savefig(::Union{PlotlyJS.SyncPlot, Plot}, ::AbstractString, ::Any...) at /home/jmb/.julia/packages/PlotlyJS/b9Efu/src/PlotlyJS.jl:49
  savefig(::PlotlyJS.SyncPlot, ::Any...; k...) at /home/jmb/.julia/packages/PlotlyJS/b9Efu/src/savefig_orca.jl:1
Stacktrace:
 [1] top-level scope at none:0

Julia version

versioninfo()
Julia Version 1.4.0-DEV.581
Commit cb8e1cfa4e (2019-12-11 18:42 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 4

jmbyars avatar Dec 13 '19 19:12 jmbyars

The savefig methods work with a plot, but not just the array of traces.

Can you try:

p = plot(plot_traces, style=boxplot_style)
savefig(p, "test.pdf")

?

sglyon avatar Dec 14 '19 14:12 sglyon