Skip to content

Commit 340e72a

Browse files
trial support of plotting in examples in docs
1 parent 474131c commit 340e72a

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

docs/Project.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
33
FastTransforms = "057dd010-8810-581a-b7be-e3fc3b93f78c"
4+
GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
45
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
6+
PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a"
7+
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
8+
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
59

610
[compat]
711
Documenter = "~0.24"

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ end
2020

2121
makedocs(
2222
doctest = false,
23-
format = Documenter.HTML(),
23+
format = Documenter.HTML(assets = [asset("https://cdn.plot.ly/plotly-1.54.7.js")]),
2424
sitename = "FastTransforms.jl",
2525
authors = "Richard Mikael Slevinsky",
2626
pages = Any[

examples/disk.jl

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
# For the storage pattern of the arrays, please consult the
2020
# [documentation](https://MikaelSlevinsky.github.io/FastTransforms).
2121

22-
using FastTransforms, LinearAlgebra
22+
using FastTransforms, LinearAlgebra, Plots
2323

2424
# Our function $f$ on the disk:
2525
f = (x,y) -> (x^2-y^2+1)/((x^2-y^2+1)^2+(2x*y+1)^2)
2626

2727
# The Zernike polynomial degree:
28-
N = 5
28+
N = 20
2929
M = 4N-3
3030

3131
# The radial grid:
@@ -37,6 +37,29 @@ r = [sinpi((N-n-0.5)/(2N)) for n in 0:N-1]
3737
# On the mapped tensor product grid, our function samples are:
3838
F = [f(r*cospi(θ), r*sinpi(θ)) for r in r, θ in θ]
3939

40+
# We superpose the grid on top of a contour plot of $f$:
41+
X = [r*cospi(θ) for r in r, θ in θ]
42+
Y = [r*sinpi(θ) for r in r, θ in θ]
43+
44+
# PyPlot
45+
pyplot()
46+
contourf(X, Y, F; levels=30, linewidth=2, xlabel="x", ylabel="y")
47+
scatter!(X, Y; legend=false, markercolor=:red, size=(600, 600))
48+
49+
# bis
50+
scatter3d(vec(X), vec(Y), vec(0X); markersize=2.0, markercolor=:red, size=(600, 600))
51+
surface!(X, Y, F; legend=false, xlabel="x", ylabel="y")
52+
53+
# PlotlyJS
54+
plotlyjs()
55+
scatter3d(vec(X), vec(Y), vec(0X); markersize=0.5, markercolor=:red, size=(600, 600))
56+
surface!(X, Y, F; legend=false, xlabel="x", ylabel="y")
57+
58+
# GR
59+
gr()
60+
scatter3d(vec(X), vec(Y), vec(0X); markersize=0.5, markercolor=:red, size=(600, 600))
61+
surface!(vec(X), vec(Y), vec(F); legend=false, xlabel="x", ylabel="y")
62+
4063
# We precompute a (generalized) Zernike--Chebyshev×Fourier plan:
4164
α, β = 0, 0
4265
P = plan_disk2cxf(F, α, β)
@@ -85,6 +108,29 @@ z = [sinpi((M-2m-1)/(2M)) for m in 0:M-1]
85108
# On the mapped tensor product grid, our function samples are:
86109
F = [f(x[n], w[n]*z) for n in 1:N, z in z]
87110

111+
# We superpose the grid on top of a contour plot of $f$:
112+
X = [x for x in x, z in z]
113+
Y = [w*z for w in w, z in z]
114+
115+
# PyPlot
116+
pyplot()
117+
contourf(X, Y, F; levels=30, linewidth=2, xlabel="x", ylabel="y")
118+
scatter!(X, Y; legend=false, markercolor=:green, size=(600, 600))
119+
120+
# bis
121+
scatter3d(vec(X), vec(Y), vec(0X); markersize=2.0, markercolor=:green, size=(600, 600))
122+
surface!(X, Y, F; legend=false, xlabel="x", ylabel="y")
123+
124+
# PlotlyJS
125+
plotlyjs()
126+
scatter3d(vec(X), vec(Y), vec(0X); markersize=0.5, markercolor=:green, size=(600, 600))
127+
surface!(X, Y, F; legend=false, xlabel="x", ylabel="y")
128+
129+
# GR
130+
gr()
131+
scatter3d(vec(X), vec(Y), vec(0X); markersize=0.5, markercolor=:green, size=(600, 600))
132+
surface!(vec(X), vec(Y), vec(F); legend=false, xlabel="x", ylabel="y")
133+
88134
# We precompute a Dunkl-Xu--Chebyshev plan:
89135
P = plan_rectdisk2cheb(F, β)
90136

0 commit comments

Comments
 (0)