-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtopoLines.jl
27 lines (27 loc) · 1.07 KB
/
topoLines.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using GLMakie
function peaks(; n = 49)
x = LinRange(-3, 3, n)
y = LinRange(-3, 3, n)
a = 3 * (1 .- x').^2 .* exp.(-(x'.^2) .- (y .+ 1).^2)
b = 10 * (x' / 5 .- x'.^3 .- y.^5) .* exp.(-x'.^2 .- y.^2)
c = 1 / 3 * exp.(-(x' .+ 1).^2 .- y.^2)
return (x, y, a .- b .- c)
end
x, y, z = peaks(; n=30)
set_theme!(theme_dark())
fig = Figure(resolution = (1200,800))
axs = [Axis3(fig[1,i]; aspect = :data) for i in 1:3]
contour3d!(axs[1], x, y, z; levels = 20, transparency = true)
contour!(axs[1], x, y, z; levels = 20, transformation = (:xy, minimum(z)),
transparency = true)
lines!(axs[2], cat(x, NaN, dims=1), y, vcat(z, fill(NaN,30)'),
color = maximum(z, dims=1)[1,:], transparency = false)
lines!(axs[2], cat(x, NaN, dims=1), y,
vcat(z, fill(NaN,30)')*0 .+ minimum(z), color = maximum(z, dims=1)[1,:],
transparency = true)
wireframe!(axs[3], x, y, z; color = :grey90, transparency = true)
wireframe!(axs[3], x, y, z*0 .+ minimum(z); color = :grey90,
transparency = true)
[hidedecorations!(ax; grid = false) for ax in axs]
save("topoLines.png", fig)
fig