diff --git a/ext/GeoStatsFunctionsMakieExt.jl b/ext/GeoStatsFunctionsMakieExt.jl index b43bc0e..773a318 100644 --- a/ext/GeoStatsFunctionsMakieExt.jl +++ b/ext/GeoStatsFunctionsMakieExt.jl @@ -12,9 +12,11 @@ import Makie import GeoStatsFunctions: varioplot, varioplot! import GeoStatsFunctions: transioplot, transioplot! +import GeoStatsFunctions: planeplot, planeplot! include("varioplot.jl") include("transioplot.jl") +include("planeplot.jl") include("utils.jl") end diff --git a/ext/planeplot.jl b/ext/planeplot.jl new file mode 100644 index 0000000..9d21a46 --- /dev/null +++ b/ext/planeplot.jl @@ -0,0 +1,80 @@ +# ------------------------------------------------------------------ +# Licensed under the MIT License. See LICENSE in the project root. +# ------------------------------------------------------------------ + +function planeplot( + g::EmpiricalVarioplane; + colormap=:viridis +) + # polar angle + θs = g.θs + + # polar radius + rs = g.rs + + # varioplane values + hs = g.hs + + # values in matrix form + H = reduce(hcat, hs) + + # exploit symmetry + θs = range(0, 2π, length=2 * length(θs)) + H = [H H] + + # hide hole at center + rs = [zero(eltype(rs)); rs] + H = [H[1:1, :]; H] + + # transpose for plotting + H = transpose(H) + + fig = Makie.Figure() + ax = Makie.PolarAxis(fig[1, 1]) + Makie.surface!(ax, θs, rs, H, colormap=colormap, shading=Makie.NoShading) + fig +end + +function planeplot( + t::EmpiricalTransioplane; + colormap=:viridis, + levels=nothing +) + # polar angle + θs = t.θs + + # polar radius + rs = t.rs + + # hide hole at center + rs = [zero(eltype(rs)); rs] + + # transioplane values + hs = t.hs + + # number of labels + L = size(first(hs), 1) + + # retrieve labels + l = isnothing(levels) ? (1:L) : levels + + fig = Makie.Figure() + for i in 1:L, j in 1:L + lᵢ, lⱼ = l[i], l[j] + ax = Makie.PolarAxis(fig[i, j], title="$lᵢ → $lⱼ") + + # values in matrix form + h = getindex.(hs, i, j) + H = reduce(hcat, h) + + # hide hole at center + H = [H[1:1, :]; H] + + # transpose for plotting + H = transpose(H) + + Makie.surface!(ax, θs, rs, H, colormap=colormap, shading=Makie.NoShading) + end + + fig +end diff --git a/ext/transioplot.jl b/ext/transioplot.jl index 7ae46a5..610f42d 100644 --- a/ext/transioplot.jl +++ b/ext/transioplot.jl @@ -62,52 +62,6 @@ function transioplot( fig end -function transioplot( - t::EmpiricalTransioplane; - # common transiogram options - levels=nothing, - # empirical transioplane options - colormap=:viridis -) - # polar angle - θs = t.θs - - # polar radius - rs = t.rs - - # hide hole at center - rs = [zero(eltype(rs)); rs] - - # transioplane values - hs = t.hs - - # number of labels - L = size(first(hs), 1) - - # retrieve labels - l = isnothing(levels) ? (1:L) : levels - - fig = Makie.Figure() - for i in 1:L, j in 1:L - lᵢ, lⱼ = l[i], l[j] - ax = Makie.PolarAxis(fig[i, j], title="$lᵢ → $lⱼ") - - # values in matrix form - h = getindex.(hs, i, j) - H = reduce(hcat, h) - - # hide hole at center - H = [H[1:1, :]; H] - - # transpose for plotting - H = transpose(H) - - Makie.surface!(ax, θs, rs, H, colormap=colormap, shading=Makie.NoShading) - end - - fig -end - # ------------ # THEORETICAL # ------------ diff --git a/ext/varioplot.jl b/ext/varioplot.jl index 4d4bc4a..9273bc3 100644 --- a/ext/varioplot.jl +++ b/ext/varioplot.jl @@ -14,13 +14,7 @@ Makie.@recipe(VarioPlot, γ) do scene showtext=true, textsize=12, showhist=true, - histcolor=:slategray, - - # empirical varioplane options - colormap=:viridis, - showrange=true, - rangecolor=:white, - rangemodel=SphericalVariogram + histcolor=:slategray ) end @@ -60,38 +54,6 @@ function Makie.plot!(plot::VarioPlot{<:Tuple{EmpiricalVariogram}}) end end -Makie.plottype(::EmpiricalVarioplane) = VarioPlot{<:Tuple{EmpiricalVarioplane}} - -function Makie.plot!(plot::VarioPlot{<:Tuple{EmpiricalVarioplane}}) - # retrieve varioplane object - γ = plot[:γ] - - # polar angle - θs = Makie.@lift $γ.θs - - # polar radius - rs = Makie.@lift $γ.rs - - # varioplane values - hs = Makie.@lift $γ.hs - - # values in matrix form - H = Makie.@lift reduce(hcat, $hs) - - # exploit symmetry - θs = Makie.@lift range(0, 2π, length=2 * length($θs)) - H = Makie.@lift [$H $H] - - # hide hole at center - rs = Makie.@lift [zero(eltype($rs)); $rs] - H = Makie.@lift [$H[1:1, :]; $H] - - # transpose for plotting - H = Makie.@lift transpose($H) - - Makie.surface!(plot, θs, rs, H, colormap=plot[:colormap], shading=Makie.NoShading) -end - # ------------ # THEORETICAL # ------------ diff --git a/src/GeoStatsFunctions.jl b/src/GeoStatsFunctions.jl index 8fbb69c..4cb3623 100644 --- a/src/GeoStatsFunctions.jl +++ b/src/GeoStatsFunctions.jl @@ -106,6 +106,8 @@ export varioplot, varioplot!, transioplot, - transioplot! + transioplot!, + planeplot, + planeplot! end diff --git a/src/plotting.jl b/src/plotting.jl index 9020262..f5aef60 100644 --- a/src/plotting.jl +++ b/src/plotting.jl @@ -5,7 +5,7 @@ """ varioplot(γ; [options]) -Plot the variogram or varioplane `γ` with given `options`. +Plot the variogram `γ` with given `options`. ## Common variogram options: @@ -21,10 +21,6 @@ Plot the variogram or varioplane `γ` with given `options`. * `showhist` - show histogram * `histcolor` - color of histogram -## Empirical varioplane options: - -* `colormap` - color map of varioplane - ### Notes * This function will only work in the presence of @@ -54,3 +50,21 @@ Plot the transiogram `t` with given `options`. """ function transioplot end function transioplot! end + +""" + planeplot(f; [options]) + +Plot the varioplane or transioplane `f` with given `options`. + +## Available options + +* `colormap` - Color map of plane plot. + +### Notes + +* This function will only work in the presence of + a Makie.jl backend via package extensions in + Julia v1.9 or later versions of the language. +""" +function planeplot end +function planeplot! end