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

Loaded notebooks have no plots #89

Closed
cstjean opened this issue Oct 19, 2016 · 5 comments
Closed

Loaded notebooks have no plots #89

cstjean opened this issue Oct 19, 2016 · 5 comments

Comments

@cstjean
Copy link
Contributor

cstjean commented Oct 19, 2016

On Julia 0.5, in IJulia,

# First cell:
using PlotlyJS
init_notebook(true)   # with or without this line, same thing

# Second cell:
t1 = scatter(;x=[1, 2, 3, 4, 5],
              y=[1, 6, 3, 6, 1])
plot([t1])

This displays a plot. But if I save the notebook and refresh the page (or reload the notebook later), then all the plots are gone. The above code just displays a blank. Plots.jl displays a "Javascript error" in red. Related to #45.

Bokeh uses this code. I haven't tried if it would solve the issue.

    import IPython.core.displaypub as displaypub
    try:
        displaypub.publish_display_data(source, data)
    except TypeError:
        displaypub.publish_display_data(data)
@sglyon
Copy link
Member

sglyon commented Oct 21, 2016

Hi @cstjean Thanks for bringing this up.

I'm a little surprised that you're seeing this behavior. One thing that might happen is if you run the using PlotlyJS cell more than once, it might remove the (hidden to us) plotly.js javascript source that is loaded when the PlotlyJS first starts up.

It isn't an issue during the same session, as your browser keeps a local copy of it in memory, but if you leave/refresh/or otherwise re-open the page then it will not be able to resurrect that javascript code.

Can you try to run the using PlotlyJS cell only one time, plot something from a different cell, then refresh and see what happens?

If you are still having issues it would be helpful if you could post the offending notebook to github or put it in a github gist so I can investigate more.

@cstjean
Copy link
Contributor Author

cstjean commented Oct 21, 2016

Thank you for the detailed answer. You were right; if I follow your steps on a fresh notebook, it works upon refresh. Plots still fails though. After refreshing the page:

screen shot 2016-10-21 at 12 23 11

Should I close this issue and open it again on Plots.jl? cc. @tbreloff

@sglyon
Copy link
Member

sglyon commented Oct 22, 2016

If it works with PlotlyJS and not Plots it sounds like an issue that should be handled over there.

What do you think @tbreloff ?

@tbreloff
Copy link
Member

Noted. I'll probably need Spencer's help to solve this even if you open a
new issue in Plots.

On Friday, October 21, 2016, Cédric St-Jean [email protected]
wrote:

Thank you for the detailed answer. You were right; if I follow your steps
on a fresh notebook, it works with using Plotly upon refresh. Plots still
fails though. After refreshing the page:

[image: screen shot 2016-10-21 at 12 23 11]
https://cloud.githubusercontent.com/assets/8622776/19610918/fec60d2e-97ac-11e6-9afe-8d37223194d2.png

Should I close this issue and open it again on Plots.jl? cc. @tbreloff
https://github.com/tbreloff


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#89 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA492pFCgJF6-wgI7roF6PF-H-GHXacOks5q2SNpgaJpZM4KbFQS
.

@pabloferz
Copy link

pabloferz commented Nov 14, 2016

A possible solution could be to have

function Plots._show(io::IO, ::MIME"image/svg+xml", plt::Plot{Plots.PlotlyJSBackend})
    if Plots.isijulia()
        write(io, PlotlyJS.html_body(PlotlyJS.JupyterPlot(plt.o)))
    else
        show(io, MIME("text/html"), plt.o)
    end
end

in Plots instead of the current _showdefinition over there.

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

4 participants