Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataInspector: fix an attribute extraction bug for heatmaps & images #3260

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/interaction/inspector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ function show_imagelike(inspector, plot, name, edge_based)
a._color[] = if z isa AbstractFloat
interpolated_getindex(
to_colormap(plot.colormap[]), z,
to_value(get(plot.attributes, :colorrange, (0, 1)))
extract_colorrange(plot)
)
else
z
Expand Down
10 changes: 10 additions & 0 deletions src/makielayout/blocks/colorbar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ function colorbar_check(keys, kwargs_keys)
end
end

function extract_colorrange(@nospecialize(plot::AbstractPlot))::Vec2{Float64}
if haskey(plot, :calculated_colors) && plot.calculated_colors[] isa Makie.ColorMapping
return plot.calculated_colors[].colorrange[]
elseif haskey(plot, :colorrange) && !(plot.colorrange[] isa Makie.Automatic)
return plot.colorrange[]
else
error("colorrange not found and calculated_colors for the plot is missing or is not a proper color map. Heatmaps and images should always contain calculated_colors[].colorrange")
end
end

function extract_colormap(@nospecialize(plot::AbstractPlot))
has_colorrange = haskey(plot, :colorrange) && !(plot.colorrange[] isa Makie.Automatic)
if haskey(plot, :calculated_colors) && plot.calculated_colors[] isa Makie.ColorMapping
Expand Down
Loading