Skip to content

Commit

Permalink
resample for series
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Sep 13, 2023
1 parent 39530e4 commit 83ade83
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
16 changes: 14 additions & 2 deletions ext/DimensionalDataMakie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,21 @@ Plot a 2-dimensional `AbstractDimArray` with `Makie.series`.
$(_labeldim_detection_doc(series))
"""
function Makie.series(A::AbstractDimArray{<:Any,2}; axislegendkw=(;), labeldim=nothing, attributes...)
function Makie.series(A::AbstractDimArray{<:Any,2};
colormap=:Set1_5, color=nothing, axislegendkw=(;), labeldim=nothing, attributes...,
)
args, merged_attributes = _series(A, attributes, labeldim)
p = Makie.series(args...; merged_attributes...)
n = size(last(args), 1)
p = if isnothing(color)
if n > 7
color = resample_cmap(colormap, n)
Makie.series(args...; color, colormap, merged_attributes...)
else
Makie.series(args...; colormap, merged_attributes...)
end
else
Makie.series(args...; color, colormap, merged_attributes...)
end
axislegend(p.axis; merge=true, unique=false, axislegendkw...)
return p
end
Expand Down
15 changes: 11 additions & 4 deletions test/plotrecipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,21 @@ if !haskey(ENV, "CI")
# Series also puts Categories in the legend no matter where they are
series(A2)
series(A2r)
dd = DimArray(rand(10,20), (:a, :b))
series(dd)
series(A2r; labeldim=Y)
@test_throws ArgumentError plot(A2; y=:c)
# x/y can be specified
A2 = DimArray(rand(10, 10), (:a, :b); name=:stuff)
A2ab = DimArray(rand(6, 10), (:a, :b); name=:stuff)
plot(A2ab)
contourf(A2ab; x=:a)
heatmap(A2ab; y=:b)
@test_throws ArgumentError plot(A2; y=:c)
series(A2ab)
boxplot(A2ab)
violin(A2ab)
rainclouds(A2ab)
surface(A2ab)
series(A2ab)
series(A2ab; labeldim=:a)
series(A2ab; labeldim=:b)
# 3d
A3 = rand(X(7), Z(10), Y(5))
volume(A3)
Expand Down

0 comments on commit 83ade83

Please sign in to comment.