diff --git a/src/common.jl b/src/common.jl index 0e1618e2..fe8c3ca5 100644 --- a/src/common.jl +++ b/src/common.jl @@ -609,10 +609,11 @@ function colormap_callback(cmap::Symbol) cdata = ColorSchemes.colorschemes[cmap] (z, minz, maxz) -> begin isfinite(z) || return INVALID_COLOR - get( - cdata, - minz == maxz ? zero(z) : (max(minz, min(z, maxz)) - minz) / (maxz - minz), - ) |> ansi_color + z01 = + minz == maxz ? zero(z) : + (max(minz, min(z, maxz)) - minz) / (maxz - minz) + isfinite(z01) || return INVALID_COLOR + ansi_color(get(cdata, z01)) end::ColorType end diff --git a/test/tst_issues.jl b/test/tst_issues.jl index a65817ea..9fd7318b 100644 --- a/test/tst_issues.jl +++ b/test/tst_issues.jl @@ -107,4 +107,13 @@ p = scatterplot(rand(1) * u"m", rand(1)) show(devnull, p) end + + @testset "Heatmap ±Inf (#378)" begin + p = heatmap([1 2; 3 -Inf]) + show(devnull, p) + p = heatmap([-Inf;;]) + show(devnull, p) + p = heatmap([1 2; 3 Inf]) + show(devnull, p) + end end