Skip to content

Commit b5ff435

Browse files
authored
Add heatmap of the zoom window to the plotattributes (#90)
* Add heatmap of the zoom window to the plotattributes * Set data_limits_ext for first iteration * Add test for plotting a pyramid and that the colorbar updates
1 parent 2ff01a7 commit b5ff435

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

ext/PyramidSchemeMakieExt.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,15 @@ function Makie.plot!(plot::Heatmap{<: Tuple{<: Pyramid}})
8181
pyramid_data_ext = Extent(X=xval, Y=yval)
8282
pyramid_ext = extent(pyramid)
8383

84-
data_limits_ext = Extent(X = extrema(first, datapos), Y = extrema(x -> x[2], datapos))
84+
data_limits_ext = if isnothing(cached)
85+
Extent(X=first(extent(pyramid, XDim)), Y=first(extent(pyramid, YDim)))
86+
else
87+
Extent(X = extrema(first, datapos), Y = extrema(x -> x[2], datapos))
88+
end
8589
pixel_widths = Point2f(abs.(pixelpos[2] .- pixelpos[1]))
8690

8791
datalimit = switchkeys(data_limits_ext, pyramid_ext)
92+
8893
if intersects(pyramid_data_ext, data_limits_ext)
8994
# @show data_limits_ext
9095
return (Ref{DD.AbstractDimMatrix}(miss2nan.(
@@ -94,8 +99,9 @@ function Makie.plot!(plot::Heatmap{<: Tuple{<: Pyramid}})
9499
return nothing # nothing changed so the downstream computation is not marked dirty
95100
end
96101
end
97-
98-
heatmap!(plot, plot.attributes, plot.__pyramid_data)
102+
zoomheat = heatmap!(plot, plot.attributes, plot.__pyramid_data)
103+
add_input!(plot.attributes, :__pyramid_heatmap, zoomheat)
104+
zoomheat
99105
end
100106

101107
function Makie.data_limits(p::Heatmap{<: Tuple{<: Pyramid}})

test/runtests.jl

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,22 @@ end
180180
@test pyrsum.levels[2][10,10] == 17
181181
end
182182

183-
183+
@testitem "Plot of Pyramid" begin
184+
using CairoMakie
185+
using YAXArrays
186+
using DimensionalData.Dimensions
187+
a = zeros(1500, 1524)
188+
a[1:100, 1:100] .= 2
189+
yax = YAXArray((X(1.:size(a,1)),Y(1.:size(a,2))), a)
190+
pyramid = Pyramid(yax)
191+
192+
# test that colorbar updates
193+
fig, ax, plt = plot(pyramid)
194+
cb = Colorbar(fig[1,2], plt.__pyramid_heatmap[])
195+
@test cb.limits[] == [0.0, 2.0]
196+
limits!(ax, 200,300, 200, 300)
197+
@test cb.limits[] == [-0.5, 0.5]
198+
end
184199
#=
185200
@testitem "Comparing zarr pyramid with tif pyramid" begin
186201
using PyramidScheme: PyramidScheme as PS

0 commit comments

Comments
 (0)