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

Error when plotting in IJulia notebooks #46

Closed
psilva07 opened this issue Jun 14, 2016 · 9 comments · Fixed by #48
Closed

Error when plotting in IJulia notebooks #46

psilva07 opened this issue Jun 14, 2016 · 9 comments · Fixed by #48

Comments

@psilva07
Copy link

I have a fresh install of Julia in a Mac and I have been trying to use the plotly library in the IJulia notebooks but it is not working. The issue is similar to https://github.com/Keno/GraphViz.jl/issues/11 but I couldn't find a solution.

I didn't install Jupyter beforehand so I'm using Miniconda. I got the plots working on the REPL with Blink but so far nothing on the notebooks. Here is what I have:

using Plots; plotly()
p = plot(rand(10), c=:red, m=(20,:green))

[Plots.jl] Initializing backend: plotly
MethodError: `_writemime` has no method matching _writemime(::Base.AbstractIOBuffer{Array{UInt8,1}}, ::MIME{symbol("image/svg+xml")}, ::Plots.Plot{Plots.PlotlyBackend})
Closest candidates are:
  _writemime(::IO, ::MIME{symbol("image/svg+xml")}, !Matched::Plots.Plot{Plots.PyPlotBackend})
  _writemime(::IO, !Matched::MIME{symbol("image/png")}, ::Plots.Plot{Plots.PlotlyBackend})
  _writemime(::IO, !Matched::MIME{symbol("text/html")}, ::Plots.Plot{Plots.PlotlyBackend})
  ...

 in writemime at /Users/pedrosilva/.julia/v0.4/Plots/src/output.jl:150
 in writemime at /Users/pedrosilva/.julia/v0.4/Plots/src/output.jl:140
 in writemime at multimedia.jl:43
 in sprint at iostream.jl:206
 in display_dict at /Users/pedrosilva/.julia/v0.4/Plots/src/output.jl:189
@tbreloff
Copy link
Member

Hi @psilva07 a couple things:

@psilva07
Copy link
Author

psilva07 commented Jun 14, 2016

Thanks @tbreloff . I did Pkg.checkout("Plots") and used plotlyjs() ranther than plotly() but still no luck:

using Plots; plotlyjs()
p = plot(rand(10), c=:red, m=(20,:green))

[Plots.jl] Initializing backend: plotlyjs
INFO: Recompiling stale cache file /Users/pedrosilva/.julia/lib/v0.4/Blink.ji for module Blink.
Plotly javascript loaded.
LoadError: MethodError: `colon` has no method matching colon(::JSON.State{false})
Closest candidates are:
  colon(::Any, !Matched::Lazy.List)
  colon{T}(::T, !Matched::T)
  colon(::Any, !Matched::Any, !Matched::Lazy.List)
  ...
while loading In[2], in expression starting on line 1

 in _print at /Users/pedrosilva/.julia/v0.4/PlotlyJS/src/json.jl:9
 in _print at /Users/pedrosilva/.julia/v0.4/JSON/src/JSON.jl:136
 in print at /Users/pedrosilva/.julia/v0.4/JSON/src/JSON.jl:204
 in sprint at iostream.jl:206
 in json at /Users/pedrosilva/.julia/v0.4/JSON/src/JSON.jl:217
 in map at tuple.jl:60
 in _call_plotlyjs at /Users/pedrosilva/.julia/v0.4/PlotlyJS/src/displays/ijulia.jl:140
 in addtraces! at /Users/pedrosilva/.julia/v0.4/PlotlyJS/src/displays/ijulia.jl:161
 in addtraces! at /Users/pedrosilva/.julia/v0.4/PlotlyJS/src/display.jl:78
 in _series_added at /Users/pedrosilva/.julia/v0.4/Plots/src/backends/plotlyjs.jl:38
 in _apply_series_recipe at /Users/pedrosilva/.julia/v0.4/Plots/src/plot.jl:204
 in _plot! at /Users/pedrosilva/.julia/v0.4/Plots/src/plot.jl:471

Thanks for pointing me out on the right direction though, I will keep looking.

@tbreloff
Copy link
Member

I saw JSON just tagged a new version... I wonder if it broke something in PlotlyJS?

Did you test both plotly() and plotlyjs()? As described in the docs, they're different backends, even though they share a lot of code. And they both work fine for me.

@psilva07
Copy link
Author

I'm getting a different error now with plotly() actually:

[Plots.jl] Initializing backend: plotly
WARNING: Couldn't initialize plotly.  (might need to install it?)
LoadError: SystemError: opening file /Users/pedrosilva/.julia/v0.4/Plots/deps/plotly-latest.min.js: No such file or directory
while loading In[3], in expression starting on line 1

@tbreloff
Copy link
Member

Pkg.build("Plots")

@psilva07
Copy link
Author

psilva07 commented Jun 14, 2016

Ow yes, I forgot that, newbie mistake. It works with plotly() now. Still does not with plotlyjs(). Thanks a lot. I will post here if I find a solution for the later.

cdsousa added a commit to cdsousa/Plotlyjs.jl that referenced this issue Jun 15, 2016
@oschulz
Copy link

oschulz commented Jun 15, 2016

I can confirm the problem (Ubuntu 14.04, 64-bit, official Julia 0.4.5 build, fresh pkg directory). #48 fixes the issue for me.

@hsseung
Copy link

hsseung commented Jun 16, 2016

I can confirm that the new version of JSON.jl breaks PlotlyJS. I downgraded to v0.5.1 and it worked again.

@sglyon
Copy link
Member

sglyon commented Jun 16, 2016

Thank you all for hunting this down. I'll merge #48 today and tag a new release on Metadata.

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

Successfully merging a pull request may close this issue.

5 participants