Skip to content

Commit

Permalink
Add boolean parameter ´compute_discrete_colormap´ to switch from cont…
Browse files Browse the repository at this point in the history
…inuous to categorical colormap
  • Loading branch information
mikelliux committed Feb 23, 2025
1 parent 03a5116 commit 61e5e2b
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/basic_recipes/tricontour.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ for specifying the triangles, otherwise an unconstrained triangulation of `xs` a
colorrange = nothing
"Sets the colormap from which the line colors are sampled."
colormap = @inherit colormap

"""
Determines whether the given colormap should be discretized based on contour levels.
- If `true`, a discrete (categorical) colormap is generated, where colors are assigned based on the provided contour levels.
- If `false`, the given colormap is used without discretization.
This setting is useful for categorical or stepped visualizations where distinct colors are needed for each contour level.
"""
compute_discrete_colormap = true

"Color transform function"
colorscale = identity
"""The alpha (transparency) value of the colormap or color attribute."""
Expand Down Expand Up @@ -261,7 +272,6 @@ function Makie.plot!(c::Tricontour{<:Tuple{<:DelTri.Triangulation, <:AbstractVec

color_args_computed = (
comp_color = colors,
comp_colormap = c._computed_colormap,
comp_colorscale = c.colorscale,
comp_colorrange = colorrange
)
Expand Down Expand Up @@ -320,9 +330,9 @@ function process_color_args(c, colors; kwargs...)
colormap = get(c, :colormap, nothing)
colorscale = get(c, :colorscale, nothing)
colorrange = get(c, :colorrange, nothing)

if isnothing(to_value(colormap))
colormap = kwargs[:computed_colormap]
compute_discrete_colormap = c.attributes[:compute_discrete_colormap]
if to_value(compute_discrete_colormap)
colormap = c.attributes[:_computed_colormap]
end

if isnothing(to_value(colorscale))
Expand Down

0 comments on commit 61e5e2b

Please sign in to comment.