Skip to content

Commit

Permalink
Fix _lookup_to_vector and _lookup_to_interval (#776)
Browse files Browse the repository at this point in the history
* Fix lookup bug

* Add some tests

* recipes
  • Loading branch information
ptiede authored Aug 21, 2024
1 parent d10d0fc commit fe39de7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ext/DimensionalDataMakie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,15 @@ function Makie.convert_arguments(t::SurfaceLikeCompat, A::AbstractDimMatrix)
end
function Makie.convert_arguments(t::Makie.ImageLike, A::AbstractDimMatrix)
A1 = _prepare_for_makie(A)
xs, ys = map(_lookup_to_intervals, lookup(A))
xs, ys = map(_lookup_to_interval, lookup(A))
# the following will not work for irregular spacings, we'll need to add a check for this.
return xs, ys, last(Makie.convert_arguments(t, parent(A1)))
end
function Makie.convert_arguments(
t::Makie.CellGrid, A::AbstractDimMatrix
)
A1 = _prepare_for_makie(A)
xs, ys = map(_lookup_to_axis, lookup(A1))
xs, ys = map(_lookup_to_vector, lookup(A1))
return xs, ys, last(Makie.convert_arguments(t, parent(A1)))
end
function Makie.convert_arguments(t::Makie.VolumeLike, A::AbstractDimArray{<:Any,3})
Expand Down
13 changes: 13 additions & 0 deletions test/plotrecipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,19 @@ end
A2m[3] = missing
A2rgb = rand(RGB, X(10:10:100), Y(['a', 'b', 'c']))

#Test whether the conversion functions work
#TODO once surface2 is corrected to use the plottrait this should
#already be tested with the usual plotting functions
M.convert_arguments(M.CellGrid(), A2)
M.convert_arguments(M.VertexGrid(), A2)
M.convert_arguments(M.ImageLike(), A2)

M.convert_arguments(M.CellGrid(), A2u)
M.convert_arguments(M.VertexGrid(), A2u)
M.convert_arguments(M.ImageLike(), A2u)



fig, ax, _ = M.plot(A2)
M.plot!(ax, A2)
fig, ax, _ = M.plot(A2m)
Expand Down

0 comments on commit fe39de7

Please sign in to comment.