Skip to content

Commit 607035c

Browse files
authored
Only eventually modify CURRENT_CPT[].bfn when it has the default values. (#1880)
1 parent 47e5c8e commit 607035c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/finish_PS_nested.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,12 @@ function colorbar_triangles(val::StrSymb)::String
104104
val_str::String = lowercase(string(val))
105105
anc = "RM"; tris = "" # Default anchor Right Middle and no triangles
106106
if (contains(val_str, "tri") && !isempty(CURRENT_CPT[])) # Sets CPT.bfn to match colormap end colors
107-
CURRENT_CPT[].bfn[1,:] .= CURRENT_CPT[].colormap[1,:]
108-
CURRENT_CPT[].bfn[2,:] .= CURRENT_CPT[].colormap[end,:]
109-
tris = contains(val_str, "high") ? "+ef" : contains(val_str, "low") ? "+eb" : "+e"
107+
if (CURRENT_CPT[].bfn[1,:] == [0.0, 0.0, 0.0] && CURRENT_CPT[].bfn[1,:] == [1.0, 1.0, 1.0])
108+
# If bfn is not set, set it to the end colors of the colormap
109+
CURRENT_CPT[].bfn[1,:] .= CURRENT_CPT[].colormap[1,:]
110+
CURRENT_CPT[].bfn[2,:] .= CURRENT_CPT[].colormap[end,:]
111+
tris = contains(val_str, "high") ? "+ef" : contains(val_str, "low") ? "+eb" : "+e"
112+
end
110113
end
111114
if (!startswith(val_str, "tri")) # Means that not just triangles were requested
112115
t::Char = val_str[1] # Accept "Top, Bot, Left" but default to Right

0 commit comments

Comments
 (0)