Hello, everyone. I’ve created a Julia package named PyPlotly.jl which provides us Julia interface for plotly .
I know, there are PlotlyJS.jl
and Plotly.jl
(including Plots.jl
with function call plotly()
), but when it comes to borrowing code written in Python, especially including import plotly.graph_objects as go
and import plotly.express as px
I think wrapping plotly with PyCall.jl is useful.
Check out the link below:
Here is a sample code.
I hope you like it. If someone wants to use this functionality, I would like to register this package.
10 Likes
Good news!!! PyPlotly.jl meets Dash.jl
opened 07:10AM - 06 Aug 20 UTC
As well as Interact.jl Contributed Examples https://github.com/JuliaGizmos/Inter… act.jl/issues/36 , it is good idea to collect examples using Dash.jl.
Here is my example
# Code
```julia
# Usage: just run this code
# tested on Julia 1.4 and 1.5 and 1.6-DEV
using Dash
using DashHtmlComponents
using DashCoreComponents
using Plots
function powplot(n)
p = plot(x -> x^n, label = "y=x^$n", xlims=[0,1])
figure = (data = Plots.plotly_series(p), layout = Plots.plotly_layout(p))
figure
end
app =
dash(external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"])
app.layout = html_div(style = Dict(:width => "50%")) do
html_h1("Hello Dash"),
html_div() do
html_div("slider", style = (width = "10%", display = "inline-block")),
html_div(dcc_slider(
id = "slider",
min = 0,
max = 9,
marks = Dict(i => "$i" for i = 0:9),
value = 1,
),style = (width = "70%", display = "inline-block"))
end,
html_br(),
dcc_graph(id = "power", figure = powplot(1))
end
callback!(app, Output("power", "figure"), Input("slider", "value")) do value
powplot(value)
end
run_server(app)
```
# Result

opened 07:10AM - 06 Aug 20 UTC
As well as Interact.jl Contributed Examples https://github.com/JuliaGizmos/Inter… act.jl/issues/36 , it is good idea to collect examples using Dash.jl.
Here is my example
# Code
```julia
# Usage: just run this code
# tested on Julia 1.4 and 1.5 and 1.6-DEV
using Dash
using DashHtmlComponents
using DashCoreComponents
using Plots
function powplot(n)
p = plot(x -> x^n, label = "y=x^$n", xlims=[0,1])
figure = (data = Plots.plotly_series(p), layout = Plots.plotly_layout(p))
figure
end
app =
dash(external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"])
app.layout = html_div(style = Dict(:width => "50%")) do
html_h1("Hello Dash"),
html_div() do
html_div("slider", style = (width = "10%", display = "inline-block")),
html_div(dcc_slider(
id = "slider",
min = 0,
max = 9,
marks = Dict(i => "$i" for i = 0:9),
value = 1,
),style = (width = "70%", display = "inline-block"))
end,
html_br(),
dcc_graph(id = "power", figure = powplot(1))
end
callback!(app, Output("power", "figure"), Input("slider", "value")) do value
powplot(value)
end
run_server(app)
```
# Result

1 Like