Skip to content

Commit

Permalink
Use plotly_traces of Plots
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Sep 14, 2023
1 parent 214413c commit 6e534c4
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions content/2.reference/3.reactive-UI/2.plotting.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,7 @@ or with the `plotly` tag in the HTML code
### Defining plots from Plots.jl

It is also possible to obtain the `plotdata` from a plot defined with
[Plots.jl](https://docs.juliaplots.org/stable/) using the PlotlyJS backend and the following function:
```julia
import PlotlyBase
function plotly_traces(plt::Plots.Plot)
traces = PlotlyBase.GenericTrace[]
for series_dict in Plots.plotly_series(plt)
plotly_type = pop!(series_dict, :type)
push!(traces, PlotlyBase.GenericTrace(plotly_type; series_dict...))
end
return traces
end
```
[Plots.jl](https://docs.juliaplots.org/stable/) using the PlotlyJS backend and the `Plots.plotly_traces` function.
The function can be used as follows:
```julia
module App
Expand All @@ -87,7 +76,7 @@ Plots.plotlyjs()

p = Plots.plot([1, 2, 3], show=false)
@app begin
@out traces = plotly_traces(p)
@out traces = Plots.plotly_traces(p)
end

function ui()
Expand Down

0 comments on commit 6e534c4

Please sign in to comment.