Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue generating figures with a for loop #165

Closed
Balinus opened this issue Jan 11, 2018 · 4 comments
Closed

Issue generating figures with a for loop #165

Balinus opened this issue Jan 11, 2018 · 4 comments

Comments

@Balinus
Copy link

Balinus commented Jan 11, 2018

Hello,

I get a strange error when trying the following code (a MWE).

for n = 1:3
    # data = matread(string(repData, ifile))["Maximums"]
    data = rand(3000, 4)

    obs = data[:, 1]
    sim = data[:, 2]
    qq = data[:, 3]
    mix = data[:, 4]
    trace1 = box(;y=obs, name = "OBS")
    trace2 = box(;y=sim, name = "SIM")
    trace3 = box(;y=qq, name = "QQ")
    trace4 = box(;y=mix, name = "MIXED")
    databox = [trace1, trace2, trace3, trace4]

    layout = Layout(;title = "Maximums (10 000 réalisations)")
    sp = PlotlyJS.plot(databox, layout)
    # filefig = string(repFigures, ifile[1:end-4], ".eps")
    filefig = string(repFigures, n, ".eps")
    PlotlyJS.savefig(sp::ElectronPlot, filefig)

end

I'm able to generate the figure and save it outside of the loop but not when I'm doing the loop. The error comes from the line
PlotlyJS.savefig(sp::ElectronPlot, filefig)

I get the following error

ERROR: LoadError: MethodError: no method matching close(::Blink.Page)
Closest candidates are:
  close(::Base.DevNullStream) at coreio.jl:16
  close(::IOStream) at iostream.jl:31
  close(::Base64EncodePipe) at base64.jl:169
  ...
Stacktrace:
 [1] close(::PlotlyJS.ElectronDisplay) at /home/proy/.julia/v0.6/PlotlyJS/src/displays/electron.jl:28
 [2] close at /home/proy/.julia/v0.6/PlotlyJS/src/displays/electron.jl:98 [inlined]
 [3] svg_data(::PlotlyJS.SyncPlot{PlotlyJS.ElectronDisplay}, ::String, ::Bool) at /home/proy/.julia/v0.6/PlotlyJS/src/displays/electron.jl:220
 [4] #savefig#223(::Symbol, ::Function, ::PlotlyJS.SyncPlot{PlotlyJS.ElectronDisplay}, ::String) at /home/proy/.julia/v0.6/PlotlyJS/src/savefig.jl:126
 [5] savefig(::PlotlyJS.SyncPlot{PlotlyJS.ElectronDisplay}, ::String) at /home/proy/.julia/v0.6/PlotlyJS/src/savefig.jl:106
 [6] macro expansion at /home/proy/Codes/Julia/Stats/figures.jl:30 [inlined]
 [7] anonymous at ./<missing>:?
 [8] include_from_node1(::String) at ./loading.jl:576
 [9] include(::String) at ./sysimg.jl:14
while loading /home/proy/Codes/Julia/Stats/figures.jl, in expression starting on line 12

Thanks!

@sglyon
Copy link
Member

sglyon commented Jan 11, 2018

Hmm, that's strange.

Can report the version numbers you have for PlotlyJS and Blink?

@ghuba
Copy link
Contributor

ghuba commented Jan 11, 2018

Can you try this?

for n = 1:3
    # data = matread(string(repData, ifile))["Maximums"]
    data = rand(3000, 4)

    obs = data[:, 1]
    sim = data[:, 2]
    qq = data[:, 3]
    mix = data[:, 4]
    trace1 = box(;y=obs, name = "OBS")
    trace2 = box(;y=sim, name = "SIM")
    trace3 = box(;y=qq, name = "QQ")
    trace4 = box(;y=mix, name = "MIXED")
    databox = [trace1, trace2, trace3, trace4]

    layout = Layout(;title = "Maximums (10 000 réalisations)")
    sp = PlotlyJS.Plot(databox, layout)
    # filefig = string(repFigures, ifile[1:end-4], ".eps")
    filefig = string(repFigures, n, ".eps")
    PlotlyJS.savefig(ElectronPlot(sp), filefig)
end

with

    sp = PlotlyJS.Plot(databox, layout)
    PlotlyJS.savefig(ElectronPlot(sp), filefig)

This works for me inside Jupyter.

@Balinus
Copy link
Author

Balinus commented Jan 11, 2018

Thanks @ghuba, it works in the REPL now. But, not with Juno.

Hence, when trying in the REPL, it works. It's only when I connect to Juno through ssh (i.e. using Juno; Juno.connect(local_ip) that it does not work.

when I connect to Juno and launch the MWE, I got an additional warning before I get the mentioned error:

WARNING: Method definition get_window(Base.Dict{K, V} where V where K) in module PlotlyJS at /home/proy/.julia/v0.6/PlotlyJS/src/displays/electron.jl:51 overwritten at /home/proy/.julia/v0.6/PlotlyJS/src/displays/juno.jl:21.

Tried with both the latest tagged and master releases of PlotlyJS and Blink.

@sglyon
Copy link
Member

sglyon commented Aug 31, 2018

savefig backend has been re-written and is much more reliable. Please try it out!

For now, please use the master branch

] # enter pkg mode
(v1.0) pkg> checkout PlotlyJS

If you want save figures you can do

] # enter package mode
(v1.0) pkg> add https://github.com/sglyon/ORCA.jl.git#master

If this doesn't resolve your issue here, please reopen the issue and leave a comment describing what went wrong

@sglyon sglyon closed this as completed Aug 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants