Skip to content

Commit

Permalink
Enhance graphics
Browse files Browse the repository at this point in the history
  • Loading branch information
pedromxavier committed Sep 27, 2024
1 parent e7d9f6d commit d4ea2cd
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/library/analysis/visualization/model_density.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,34 @@ function ModelDensityPlot(model::Any)
return ModelDensityPlot(backend(model))
end

function _model_density_ticks(
n::Integer,
p::Integer = (n <= 16) ? n : 8,
)
if n <= p
return collect(Int, 1:n)
else
k = round(Int, n / p)

return [1;(k+1):k:(n-k);n]
end
end

@recipe function plot(plt::ModelDensityPlot{V,T,U,M}) where {V,T,U,M}
title --> "Model Density"
color --> :balance
xlabel --> "Variable Index"
ylabel --> "Variable Index"
margin --> (0.5, :cm)
fontfamily --> "Computer Modern"

top_margin --> ( 0, :px)
bottom_margin --> ( 0, :px)
left_margin --> (20, :px)
right_margin --> (20, :px)

n, L, Q, α = form(plt.model, :dense)

t = collect(1:(n÷10+1):n)
t = _model_density_ticks(n)
z = α * (Symmetric(Q / 2) + diagm(L))

Γ = maximum(abs.(z))
Expand All @@ -32,6 +49,8 @@ end
xmirror := true
seriestype := :heatmap
aspect_ratio := :equal
framestyle := :grid
size := (505, 500)

return (1:n, 1:n, collect(z))
end

0 comments on commit d4ea2cd

Please sign in to comment.