Skip to content

Commit

Permalink
more tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Feb 11, 2024
1 parent 232a9ba commit 7b294fc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
12 changes: 8 additions & 4 deletions ext/DimensionalDataMakie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ for f in (:volume, :volumeslices)
@eval begin
@doc $docstring
function Makie.$f(A::AbstractDimArray{<:Any,3}; attributes...)
replacements = _keywords2dimpairs(x, y, z)
A1, A2, args, merged_attributes = _volume3(A; attributes...)
p = Makie.$f(args...; merged_attributes...)
p.axis.scene[OldAxis][:names, :axisnames] = map(DD.label, DD.dims(A2))
Expand All @@ -341,7 +340,7 @@ end

function Makie.plot(A::AbstractDimArray{<:Any,3}; kw...)
if all(isintervals(dims(A)))
Makie.volume(A; kw...)
Makie.volume(A; interpolate=false, kw...)
elseif count(isintervals(A)) == 2
Makie.poly(A; kw...)
elseif count(isintervals(A)) == 1
Expand All @@ -352,7 +351,7 @@ function Makie.plot(A::AbstractDimArray{<:Any,3}; kw...)
end
function Makie.plot!(ax, A::AbstractDimArray{<:Any,3}; kw...)
if all(isintervals(A))
Makie.volume!(ax, A; kw...)
Makie.volume!(ax, A; interpolate=false, kw...)
elseif count(isintervals(A)) == 2
Makie.poly!(ax, A; kw...)
elseif count(isintervals(A)) == 1
Expand All @@ -369,6 +368,7 @@ function Makie.poly(A::AbstractDimArray{<:Any,3}; attributes...)
# TODO this doesn't plot properly?
# All polygons plat on the same plane
p = Makie.poly(polys; color=vec(A2), merged_attributes...)
p.axis.scene[OldAxis][:names, :axisnames] = map(DD.label, DD.dims(A2))
return p
end

Expand All @@ -382,19 +382,23 @@ function Makie.linesegments(A::AbstractDimArray{<:Any,3}; attributes...)
A1, A2, args, merged_attributes = _volume3(A; attributes...)
lines = vec(collect(DimLines(A)))
p = Makie.linesegments(lines; color=vec(A), merged_attributes...)
p.axis.scene[OldAxis][:names, :axisnames] = map(DD.label, DD.dims(A2))
return p
end

function Makie.linesegments!(ax, A::AbstractDimArray{<:Any,3}; attributes...)
A1, A2, args, merged_attributes = _surface2(A; attributes...)
lines = collect(vec(DimLines(A)))
return Makie.linesegments!(ax, lines; colors=vec(A), merged_attributes...)
p = Makie.linesegments!(ax, lines; colors=vec(A), merged_attributes...)
p.axis.scene[OldAxis][:names, :axisnames] = map(DD.label, DD.dims(A2))
return p
end

function Makie.scatter(A::AbstractDimArray{<:Any,3}; attributes...)
A1, A2, args, merged_attributes = _volume3(A; attributes...)
points = vec(collect(DimPoints(A2)))
p = Makie.scatter(points; color=vec(A), merged_attributes...)
p.axis.scene[OldAxis][:names, :axisnames] = map(DD.label, DD.dims(A2))
return p
end

Expand Down
10 changes: 5 additions & 5 deletions test/plotrecipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ using ColorTypes
M.series!(ax, A2m)
@test_throws ArgumentError M.plot(A2; y=:c)
@test_throws ArgumentError M.plot!(ax, A2; y=:c)
A2intervals1 = rand(X(10:10:100; sampling=Intervals(Start())), Y(1:3))
A2intervals1 = rand(X(10:10:100; sampling=Intervals(Start())), Z(1:3))
M.plot(A2intervals1)
A2intervals2 = rand(X(10:10:100; sampling=Intervals(Start())), Y(1:3; sampling=Intervals(Start())))
A2intervals2 = rand(X(10:10:100; sampling=Intervals(Start())), Z(1:3; sampling=Intervals(Start())))
M.plot(A2intervals2)

# x/y can be specified
Expand Down Expand Up @@ -316,10 +316,10 @@ using ColorTypes
fig, ax, _ = M.volumeslices(A3abc; z=:a)
M.volumeslices!(ax, A3abc;z=:a)

A3intervals1 = rand(X(10:1:20; sampling=Intervals(Start())), Y(1:3), Z(10:20))
M.plot(A3intervals1)
A3intervals1 = rand(X(10:1:15; sampling=Intervals(Start())), Y(1:3), Dim{:C}(10:15))
M.plot(A3intervals1; z=:C)
# Broken from here
A3intervals2 = rand(X(10:1:20; sampling=Intervals(Start())), Y(1:3), Z(10:20; sampling=Intervals(Start())))
A3intervals2 = rand(X(10:1:15; sampling=Intervals(Start())), Y(1:3), Z(10:15; sampling=Intervals(Start())))
M.plot(A3intervals2)
A3intervals2a = rand(X(10:1:10; sampling=Intervals(Start())), Y(1:1; sampling=Intervals(Start())), Z(10:20))
M.plot(A3intervals2a)
Expand Down

0 comments on commit 7b294fc

Please sign in to comment.