let
estilo = Dict("A" => (AZUL, :solid), "B" => (NARANJA, :dash), "C" => (VERDE, :dot))
fig = Figure(size=(504, 210), fontsize=9)
axa = Axis(fig[1, 1], xlabel="frecuencia (Hz)", ylabel="PSD ((m/s²)²/Hz)", yscale=log10, limits=((3.8, 5.0), nothing))
for (esc, _, _) in estados
f, P = psd_welch(datos[esc].a3_ms2, 100.0; nseg=4096)
m = 3.8 .<= f .<= 5.0
lines!(axa, f[m], P[m], color=estilo[esc][1], linestyle=estilo[esc][2], linewidth=1.4, label=esc)
end
axislegend(axa, "estado", position=:rt, framevisible=false, patchsize=(18, 8))
ejes = Any[axa]
for (j, (datos_f, ylab, k)) in enumerate([(f3, "f₃ (Hz)", 3), (f1, "f₁ (Hz)", 1)])
ax = Axis(fig[1, 1+j], ylabel=ylab, xlabel="estado", xticks=(1:3, ["A", "B", "C"]))
push!(ejes, ax)
for (i, (esc, _, _)) in enumerate(estados)
boxplot!(ax, fill(i, 10), datos_f[esc], color=(estilo[esc][1], 0.25), width=0.55, strokecolor=estilo[esc][1], whiskercolor=estilo[esc][1])
scatter!(ax, i .+ 0.08 .* (rand(MersenneTwister(i), 10) .- 0.5), datos_f[esc], color=estilo[esc][1], markersize=4)
hlines!(ax, modelo[esc][k], xmin=(i-0.4)/3.2, xmax=(i+0.4)/3.2, color=:black, linestyle=:dash, linewidth=1)
end
end
for (ax, letra) in zip(ejes, ("a", "b", "c"))
text!(ax, 0.03, 0.96, text="($letra)", space=:relative, align=(:left, :top), font=:bold, fontsize=11)
end
colgap!(fig.layout, 14)
fig
end