Skip to content

Commit

Permalink
add byrow
Browse files Browse the repository at this point in the history
  • Loading branch information
kongdd committed Jul 11, 2024
1 parent c7e9988 commit 87baefd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/Layers/imagesc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ function imagesc!(fig::Union{Figure,GridPosition,GridSubposition},
kw_cbar=(;),
cbar_width=15,
fun_axis=nothing,
byrow=false,
kw...) where {R<:AbstractArray{<:Real,3}}

length(gap) == 1 && (gap = (gap, gap, 5))
Expand All @@ -89,9 +90,15 @@ function imagesc!(fig::Union{Figure,GridPosition,GridSubposition},
plts = []

k = 0
for i = 1:nrow, j = 1:ncol
inds = byrow ? CartesianIndices((1:ncol, 1:nrow)) : CartesianIndices((1:nrow, 1:ncol))

for I in inds[1:n]
if byrow
i, j = I[2], I[1]
else
i, j = I[1], I[2]
end
k += 1
k > n && break

title = titles[k]
if isa(z, Observable)
Expand All @@ -105,6 +112,7 @@ function imagesc!(fig::Union{Figure,GridPosition,GridSubposition},
push!(axs, ax)
push!(plts, plt)
end

linkaxes!(axs...)
bind_z!(plts, z)

Expand Down
5 changes: 4 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,18 @@ end
save("test.png", fig)
end

@testset "imagesc" begin
@testset "imagesc extra" begin
x = 2:11
y = 2:11
fig = Figure(; size=(800, 800))
@test_nowarn imagesc!(fig[1:2, 1:2], x, y, rand(10, 10, 4);
colorrange=(0, 1), gap=(0, 0, 25))
fig

@test_nowarn imagesc(rand(4, 4, 12), layout=(4, 3), byrow=true)
end


@testset "ncl" begin
@test_nowarn ncl_colors
@test_nowarn ncl_group
Expand Down

0 comments on commit 87baefd

Please sign in to comment.