Skip to content

Do you think this package would enable a person to plot Python Plotly code in a julia notebook? #14

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

Open
russelljjarvis opened this issue May 1, 2022 · 12 comments

Comments

@russelljjarvis
Copy link

Do you think your package would enable a person to plot Python Plotly code in a julia notebook or Pluto?

I think the variety of possible and tested plots is reduced for julia plotly versus python plotly especially for network apps. I want to make a julia dashboard app, that resuses already established Python plotly apps where possible.

@terasakisatoshi
Copy link
Member

Hi @russelljjarvis

Thank you for finding this pacakge.

Do you think your package would enable a person to plot Python Plotly code in a julia notebook or Pluto?

I believe we can display fig object in a Jupyter Notebook.

image

@terasakisatoshi
Copy link
Member

If you like to create application with Dash.jl check this out:

plotly/Dash.jl#50 (comment)

@terasakisatoshi
Copy link
Member

terasakisatoshi commented May 1, 2022

Our package converts Python plotly objects into PlotlyJS.jl objects using the following code:

function create_plotlyjs(fig::GraphObjects.Figure)
jsonobj = JSON.parse(fig.to_json())
traces = PlotlyJS.GenericTrace.(jsonobj["data"])
layout = PlotlyJS.Layout(jsonobj["layout"])
return PlotlyJS.plot(traces, layout)
end
function Base.show(io::IO, mime::MIME, fig::GraphObjects.Figure)
show(io, mime, create_plotlyjs(fig))
end
function Base.display(::PlotlyJS.PlotlyJSDisplay, fig::GraphObjects.Figure)
PlotlyJS.display_blink(create_plotlyjs(fig))
end

Therefore our package should work as long as PlotlyJS.jl lives.

@russelljjarvis
Copy link
Author

Argghh!! that is the best part. Thanks that perfectly answers my question.

@russelljjarvis
Copy link
Author

If you like to create application with Dash.jl check this out:

plotly/Dash.jl#50 (comment)

I am torn between dash.jl and pluto.jl I think its too much work to keep track of HTML divs. In Python, streamlit has meant you can make web apps without managing all the HTML, I am hoping to find a similar approach to streamlit in Julia, Pluto might work. So far using plotly.jl in pluto gives me errors, so I might come around to dash after all.

@terasakisatoshi
Copy link
Member

Hi, @russelljjarvis

I've updated PyPlotly so that we can display plotly object on Pluto notebook.

image

How to reproduce:

Clone PyPlotly again (or run git pull to get the latest update.)

$ git clone https://github.com/AtelierArith/PyPlotly.jl.git
$ cd PyPlotly.jl
$ julia --project=@. -e 'using Pkg; Pkg.instantiate()'

Then, initialize Pluto.jl via julia> using Pluto; Pluto.run() from /path/to/PyPlotly.jl.

Access to https://github.com/AtelierArith/PyPlotly.jl/blob/main/playground/pluto/jlsample.jl

@russelljjarvis
Copy link
Author

This is super interesting. Thanks for continuing the thread, I will replicate it!

@russelljjarvis
Copy link
Author

russelljjarvis commented May 30, 2022

I replicated it, its great the real time CPU visualization with plotly works on my computer!

Do you think you could build it on pluto-on-binder too?

http://pluto-on-binder.glitch.me/

This would be like a public dashboard portal almost.

@terasakisatoshi
Copy link
Member

Do you think you could build it on pluto-on-binder too?

It seems this is not easy than we expected. Below is a screenshot.

image

@russelljjarvis
Copy link
Author

No worries. You have created a great tool. I think public julia dashboards are still in the early days.

have you seen next journal? Its not really like a public dashboard website, but it at least renders and makes shareable interactive diagrams in Julia notebooks
https://nextjournal.com/julia

There are instructions on how to setup PlutoSliderServer here for deployment on something like digital ocean, but it does not look fun.
https://juliahub.com/ui/Packages/PlutoSliderServer/NwWkP/0.3.10

@terasakisatoshi
Copy link
Member

terasakisatoshi commented Jun 1, 2022

No worries. You have created a great tool.

Thank you so much! 😄

I think public julia dashboards are still in the early days.

Well, there is a Julia library https://github.com/GenieFramework/Stipple.jl

have you seen next journal? Its not really like a public dashboard website, but it at least renders and makes shareable interactive diagrams in Julia notebooks
https://nextjournal.com/julia

Yes, this is very cool I think.

@russelljjarvis
Copy link
Author

I think the deployment options are:

  • Heroku (did not work for me).
  • Azure (people are reporting success for julia dash boards).
  • http://pluto-on-binder.glitch.me/
  • Digital Ocean (flexible but undocumented).
  • AWS Docker (AWS is complex and intimidating, compared to heroku).

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

2 participants