Skip to content

Commit

Permalink
Harden colorbar
Browse files Browse the repository at this point in the history
  • Loading branch information
kbarros committed Aug 31, 2024
1 parent 4c3b25b commit f3e88e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/07_Dipole_Dipole.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ res3 = intensities_bands(swt, path)
# slight corrections are needed for the third dispersion band.

fig = Figure(size=(768, 300))
plot_intensities!(fig[1, 1], res1; units, title="Local Exchange Only")
ax = plot_intensities!(fig[1, 2], res2; units, title="Local Exchange and Dipole-Dipole")
plot_intensities!(fig[1, 1], res1; units, title="Without long-range dipole")
ax = plot_intensities!(fig[1, 2], res2; units, title="With long-range dipole")
for c in eachrow(res3.disp)
lines!(ax, eachindex(c), c; linestyle=:dash, color=:black)
end
Expand Down
6 changes: 6 additions & 0 deletions ext/PlottingExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,12 @@ function colorrange_from_data(; data, saturation, sensitivity, allpositive)
cmax = Statistics.quantile(vec(maximum(data; dims=1)), saturation)
cmin = Statistics.quantile(vec(minimum(data; dims=1)), 1 - saturation)

# Finite range needed to prevent crash of Makie.Colorbar
if cmax == cmin
cmax += 1e-12
cmin -= 1e-12
end

if allpositive
return (sensitivity, 1) .* cmax
else
Expand Down

0 comments on commit f3e88e6

Please sign in to comment.