Fix for regression

This commit is contained in:
Nicholas Bauer 2021-10-10 13:42:45 -04:00
parent 9941563b0b
commit 7197127abe

View File

@ -5,11 +5,14 @@ process_clims(s::Union{Symbol,Nothing,Missing}) = ignorenan_extrema
# don't specialize on ::Function otherwise python functions won't work # don't specialize on ::Function otherwise python functions won't work
process_clims(f) = f process_clims(f) = f
get_clims(sp::Subplot)::Tuple{Float64,Float64} = sp[:crange] const sp_clims = Dict{Subplot, Tuple{Float64, Float64}}()
get_clims(series::Series)::Tuple{Float64,Float64} = series[:crange] const series_clims = Dict{Series, Tuple{Float64, Float64}}()
get_clims(sp::Subplot)::Tuple{Float64,Float64} = sp_clims[sp]
get_clims(series::Series)::Tuple{Float64,Float64} = series_clims[series]
get_clims(sp::Subplot, series::Series)::Tuple{Float64,Float64} = get_clims(sp::Subplot, series::Series)::Tuple{Float64,Float64} =
series[:colorbar_entry] ? sp[:crange] : series[:crange] series[:colorbar_entry] ? sp_clims[sp] : series_clims[series]
function update_clims(sp::Subplot, op = process_clims(sp[:clims]))::Tuple{Float64,Float64} function update_clims(sp::Subplot, op = process_clims(sp[:clims]))::Tuple{Float64,Float64}
zmin, zmax = Inf, -Inf zmin, zmax = Inf, -Inf
@ -20,12 +23,11 @@ function update_clims(sp::Subplot, op = process_clims(sp[:clims]))::Tuple{Float6
update_clims(series, op) update_clims(series, op)
end end
end end
return sp[:crange] = zmin <= zmax ? (zmin, zmax) : (NaN, NaN) return sp_clims[sp] = zmin <= zmax ? (zmin, zmax) : (NaN, NaN)
end end
""" """
update_clims(::Series, op=Plots.ignorenan_extrema) update_clims(::Series, op=Plots.ignorenan_extrema)
Finds the limits for the colorbar by taking the "z-values" for the series and passing them into `op`, Finds the limits for the colorbar by taking the "z-values" for the series and passing them into `op`,
which must return the tuple `(zmin, zmax)`. The default op is the extrema of the finite which must return the tuple `(zmin, zmax)`. The default op is the extrema of the finite
values of the input. The value is stored as a series property, which is retrieved by `get_clims`. values of the input. The value is stored as a series property, which is retrieved by `get_clims`.
@ -45,7 +47,7 @@ function update_clims(series::Series, op = ignorenan_extrema)::Tuple{Float64,Flo
zmin, zmax = _update_clims(zmin, zmax, op(vals)...) zmin, zmax = _update_clims(zmin, zmax, op(vals)...)
end end
end end
return series[:crange] = zmin <= zmax ? (zmin, zmax) : (NaN, NaN) return series_clims[series] = zmin <= zmax ? (zmin, zmax) : (NaN, NaN)
end end
_update_clims(zmin, zmax, emin, emax) = NaNMath.min(zmin, emin), NaNMath.max(zmax, emax) _update_clims(zmin, zmax, emin, emax) = NaNMath.min(zmin, emin), NaNMath.max(zmax, emax)