Skip to content

Commit

Permalink
use postprocessing to get HTML figures
Browse files Browse the repository at this point in the history
  • Loading branch information
MikaelSlevinsky committed Nov 26, 2020
1 parent 9b1d77a commit ecc0e59
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
11 changes: 9 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,21 @@ examples = [
"triangle.jl",
]

function uncomment_objects(str)
str = replace(str, "###```@raw" => "```\n\n```@raw")
str = replace(str, "###<object" => "<object")
str = replace(str, "###```\n```" => "```")
str
end

for example in examples
example_filepath = joinpath(EXAMPLES_DIR, example)
Literate.markdown(example_filepath, OUTPUT_DIR; execute=true)
Literate.markdown(example_filepath, OUTPUT_DIR; execute=true, postprocess = uncomment_objects)
end

makedocs(
doctest = false,
format = Documenter.HTML(assets = [asset("https://cdn.plot.ly/plotly-1.54.7.js")]),
format = Documenter.HTML(),
sitename = "FastTransforms.jl",
authors = "Richard Mikael Slevinsky",
pages = Any[
Expand Down
14 changes: 12 additions & 2 deletions examples/disk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
# [documentation](https://MikaelSlevinsky.github.io/FastTransforms).

using FastTransforms, LinearAlgebra, Plots
const GENFIGS = joinpath(dirname(dirname(pathof(FastTransforms))), "docs/src/generated")
!isdir(GENFIGS) && mkdir(GENFIGS)
plotlyjs()

# Our function $f$ on the disk:
Expand All @@ -41,8 +43,12 @@ F = [f(r*cospi(θ), r*sinpi(θ)) for r in r, θ in θ]
# We superpose a surface plot of $f$ on top of the grid:
X = [r*cospi(θ) for r in r, θ in θ]
Y = [r*sinpi(θ) for r in r, θ in θ]
scatter3d(vec(X), vec(Y), vec(0F); markersize=0.75, markercolor=:red, size=(1000, 1000))
scatter3d(vec(X), vec(Y), vec(0F); markersize=0.75, markercolor=:red, size=(800, 600))
surface!(X, Y, F; legend=false, xlabel="x", ylabel="y", zlabel="f")
savefig(joinpath(GENFIGS, "zernike.html"))
###```@raw html
###<object type="text/html" data="../zernike.html" style="width:100%;height:600px;"></object>
###```

# We precompute a (generalized) Zernike--Chebyshev×Fourier plan:
α, β = 0, 0
Expand Down Expand Up @@ -95,8 +101,12 @@ F = [f(x[n], w[n]*z) for n in 1:N, z in z]
# We superpose a surface plot of $f$ on top of the grid:
X = [x for x in x, z in z]
Y = [w*z for w in w, z in z]
scatter3d(vec(X), vec(Y), vec(0F); markersize=0.75, markercolor=:green, size=(1000, 1000))
scatter3d(vec(X), vec(Y), vec(0F); markersize=0.75, markercolor=:green, size=(800, 600))
surface!(X, Y, F; legend=false, xlabel="x", ylabel="y", zlabel="f")
savefig(joinpath(GENFIGS, "dunklxu.html"))
###```@raw html
###<object type="text/html" data="../dunklxu.html" style="width:100%;height:600px;"></object>
###```

# We precompute a Dunkl-Xu--Chebyshev plan:
P = plan_rectdisk2cheb(F, β)
Expand Down

0 comments on commit ecc0e59

Please sign in to comment.