When I try to use Plotly in Julia Notebook, I get the following error:
WebIO not detected.
Please read the troubleshooting guide for more information on how to resolve this issue.
https://juliagizmos.github.io/WebIO.jl/latest/troubleshooting/not-detected/
Here is the process I used to install julia and configure:
python -m venv julia
source julia/bin/activate
python -m pip install --upgrade pip
python -m pip install jupyter jupyterlab webio_jupyter_extension
curl -fsSL https://install.julialang.org | sh -s -- --default-channel=lts
julia
julia> using Pkg
julia> pkg"add IJulia"
julia> pkg"add Plotly"
julia> using IJulia
julia> notebook()
Then in the notebook:
using Plotly
my_plot = plot([scatter(x=[1,2], y=[3,4])], Layout(title="My plot"))
This is when I get the error mentioned above. I have tried a couple different versions of python and julia… 1.11.3 has an issue building WebIO, so I am using LTS here. Any help appreciated.
I would suggest to try using directly PlotlyLight.jl or PlotlyBase.jl if you just want to use it in jupyter as you don’t definitely need the WebIO part in jupyter and that is the cause of most problems with PlotlyJS and derivatives…
Could you please give an example of plot using only PlotlyBase, not PlotlyJS. It is of interest for google colab where I don’t know how to install a webio extension.
Hi @empet, it seems there was a bug introduced in the display method within IJulia when the PlotlyBase IJulia extension was added.
I filed a PR here but you should be able to fix this in the notebook itself thanks to @eval while waiting for the PR (or any alternative fix) to be merged and published:
You can check an example colab notebook with fix at this link
Edit:
Here is also the snippet of code to evaluate in the notebook assuming you have using PlotlyBase in another cell:
@eval IJulia function display_dict(p::$Plot)
Dict(
"application/vnd.plotly.v1+json" => $PlotlyBase.JSON.lower(p),
"text/plain" => sprint(show, "text/plain", p),
"text/html" => let
buf = IOBuffer()
show(buf, MIME("text/html"), p)
String(take!(buf))
end
)
end