Plots.jl: Plots don't show in IJulia

Created on 10 Mar 2017  Â·  30Comments  Â·  Source: JuliaPlots/Plots.jl

Anyone has come across the issue, that plots sporadically don't show up in IJulia notebooks?
I have come across this one time myself and it went away after restarting the whole IJulia process.
We currently have students using IJulia and Plots and because of their large number, this sporadic issue pops up relatively often and sometimes doesn't seem to go away as easily.
Any ideas where possible problems could be? We're using plotlyjs as the backend, julia 0.5 and the currently tagged Plots version.

cc:
@stevengj, you probably know IJulia and it's display stack better than anyone
@alanedelman

IJulia Plotly

Most helpful comment

would be good to have this one solved

All 30 comments

would be good to have this one solved

We just got another data point, that is only fixed by completely restarting the PC!
Might this pin down the problem further? What kind of state persists in IJulia/Plots, that only gets reseted with a restart?

Do you need it to be PlotlyJS? Try plotly() or gr()?

If it persists you should open an issue with PlotlyJS. I'm not able to
help.

On Fri, Mar 10, 2017 at 8:45 AM Simon notifications@github.com wrote:

We just got another data point, that is only fixed by completely
restarting the PC!
Might this pin down the problem further? What kind of state persists in
IJulia/Plots, that only gets reseted with a restart?

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/JuliaPlots/Plots.jl/issues/725#issuecomment-285672185,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA492meEhhjGGKMq2XAeeOwxj1hWCqtlks5rkVPzgaJpZM4MZPQ4
.

Are you sure it's a plotlyjs issue, though?
Was less reliable in my tests, so we stopped using it, besides the interactivity of plotlyjs was more appealing!

I have had this recurrently with the plotlyjs() backend. There is also often an issue with plot! in atom. That backend would need a little attention to come on a par with the other backends.

I don't often use this particular backend, but it might be related to the following issue: https://github.com/JuliaPlots/Plots.jl/issues/699 .

From what I can gather, there appears to be an issue with Julia's tempname() function - at least in Windows.

It appears Pedro encounters a similar issue when generating a large number of plots.

I suspect that, if there is a bug with tempname(), it is being aggravated by not deleting the temporary files these backends create.

(Could it be a Javascript problem with the browser? Is it browser-dependent?)

I've had it in Firefox only (but I only use Firefox)

I believe it's just a PlotlyJS issue. I don't have problems with Plotly, GR, or PyPlot backends for this. But PlotlyJS never seems to show in notebooks for me. I always thought it was a non-issue though since you could use Plotly for it.

@ChrisRackauckas I have tried to reproduce the error several times, but cannot get it to repeat. If you can reproduce, can you save the Plots.Plot object as a jld file and pass it to me? (and perhaps try plotting with PlotlyJS outside Plots in the same session?) I just want to make sure I could get the object to plot on my system.

Oh wait, Plots.Plot objects are not JLD compatible :-(

I am having the same issue, it would be great to have it solved.

What exactly reproduces the issue? versioninfo? This is an elusive issue to catch.

My guess is that this issue is somehow related to system updates, I had updated my Linux kernel this morning and the plots were not shown when I started my Jupyter session. After reboot, it worked again.

These kernel updates leave some unfinished state in the system, for example, I cannot plug and play my pendrive after a kernel update and have it be automatically detected and mounted. This is a guess, but I don't know what is happening with PlotlyJS.

Hm, that is not enough to go on. If it reappears, will you try it in different browsers before restarting?

Yes, sorry I restarted it right away, I need to get done with something quickly, next time I will try other browsers.

Ok, it has happened again just now. What would you like me to do to get more information about this random state?

I use Chromium by default, just tried with Firefox directly after and it worked just fine. So I guess this confirms that the issue is not in Plots.jl nor PlotlyJS.jl, but in the interaction with the browser, javascript, etc.

Thank you @juliohm ! @stevengj this appears to confirm or at least support your intuition. Any idea where this should be adressed - in IJulia.jl perhaps?

I’m sorry to bother you. For these days, I also had the same issue relating to the plotlyjs backend in Plots.jl. Also I had a problem of those figures not shown in nbviewer.

I guess the cause is the plotlyjs script not embedded in the notebook, which is necessary for showing figures.

The plotlyjs() function internally calls PlotlyJS.init_notebooks(force=?) which embeds plotlyjs script in the Out cell for interactive plots, but it works only for the first time it’s called.
In other words, if the cell calling plotlyjs backend is deleted, even if the plotlyjs backend is newly called again, it won’t embed the script into the cell, though plotting is possible at that time due to the remaining plotlyjs script in the memory.

Thus the following procedure was effective for me.

  1. To embed the plotlyjs script, create a cell anywhere containing
    julia using PlotlyJS.init_notebook init_notebook(true)
    or
    julia using Plots plotlyjs() #make sure no plotlyjs() is called before this.
  2. Shutdown the notebook and reopen it.

I hope this helps.

Very interesting, thanks for the hint. Especially the case with the deleted call to plotlyjs() is potentially interesting and worth looking out for. Now if we could only think of a way to deal with this from the side of inside Plots.

I'm also having this issue sometimes with juliabox.

I'm my case the following code has this strange behavior (sometimes plots doesn't appear):

using Plots
plotlyjs()
plot(rand(10),rand(10))
for i = 1:3
    plot!(rand(10),rand(10))
end

My solution was to put a plot at the end to force some output

using Plots
plotlyjs()
plot(rand(10),rand(10))
for i = 1:3
    plot!(rand(10),rand(10))
end
plot!(rand(10),rand(10))

But I'm also getting this behavior with this simple code:

using Plots
plotlyjs()

plot(rand(10),rand(10))

In this case @nswa17 tip works.

Yes, you have to return the Plot object to the console to get an output. A for loop doesn't do that. That's normal Plots behaviour.

@mkborregaard so how to show plots in for loop? I just need to emit a separate plot in each iteration, that's quite straightforward to do in Python. I've tried

for i in 1:10
    display(plot(rand(5)))
end

to no avail.

So you need to get the plots in separate windows?

I believe the reuse = false functionality is broken on GR. The window opening behaviour of backends is something that is hard for Plots to deal with. I'd probably show them as separate subplots if you do need separate plots:

p = [plot(rand(5)) for i in 1:10]
plot(p...)

Can this be closed?

It is still a problem. I get no output with Jupyter Notebook and gr() backend. Works with pyplot(). Always something... Maybe a different choice of output type?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

apalugniok picture apalugniok  Â·  3Comments

Cody-G picture Cody-G  Â·  4Comments

daschw picture daschw  Â·  3Comments

asinghvi17 picture asinghvi17  Â·  3Comments

kersulis picture kersulis  Â·  5Comments