Skip to content

Commit

Permalink
fix plot for reverse order index
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Apr 15, 2020
1 parent 725784d commit f0cc250
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions src/plotrecipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@ struct HistogramLike end
struct ViolinLike end

@recipe function f(A::AbstractDimensionalArray)
Af = forwardorder(A)
Afwd = forwardorder(A)
sertype = get(plotattributes, :seriestype, :none)
if !(sertype in [:marginalhist])
:title --> refdims_title(A)
:title --> refdims_title(Afwd)
end
if sertype in [:heatmap, :contour, :volume, :marginalhist, :image,
:surface, :contour3d, :wireframe, :scatter3d]
HeatMapLike(), Af
HeatMapLike(), Afwd
elseif sertype in [:histogram, :stephist, :density, :barhist, :scatterhist, :ea_histogram]
HistogramLike(), Af
HistogramLike(), Afwd
elseif sertype in [:hline]
:ylabel --> label(A)
data(Af)
:ylabel --> label(Afwd)
data(Afwd)
elseif sertype in [:vline, :andrews]
:xlabel --> label(A)
data(Af)
:xlabel --> label(Afwd)
data(Afwd)
elseif sertype in [:violin, :dotplot, :boxplot]
ViolinLike(), Af
ViolinLike(), Afwd
elseif sertype in [:plot, :histogram2d, :none, :line, :path, :steppre, :steppost, :sticks, :scatter,
:hexbin, :barbins, :scatterbins, :stepbins, :bins2d, :bar]
SeriesLike(), Af
SeriesLike(), Afwd
else
data(Af)
data(Afwd)
end
end

Expand Down Expand Up @@ -95,14 +95,8 @@ end

maybe_permute(A, dims) = all(hasdim(A, dims)) ? permutedims(A, dims) : A

forwardorder(A) = begin
for (i, dim) in enumerate(dims(A))
if arrayorder(dim) == Reverse()
A = reverse(A; dims=dim)
end
end
A
end
forwardorder(A::AbstractArray) =
reorderindex(A, Forward()) |> a -> reorderrelation(a, Forward())

refdims_title(A::AbstractArray) = join(map(refdims_title, refdims(A)), ", ")
refdims_title(dim::Dimension) = string(name(dim), ": ", refdims_title(mode(dim), dim))
Expand Down

0 comments on commit f0cc250

Please sign in to comment.