AlgebraOfGraphics.jl icon indicating copy to clipboard operation
AlgebraOfGraphics.jl copied to clipboard

Support Waterfall plot type

Open daschw opened this issue 9 months ago • 10 comments

Before these changes

using CairoMakie
using AlgebraOfGraphics
df = (
    x=repeat(1:2, inner=5),
    y=[6, 4, 2, -8, 3, 5, 1, -2, -3, 7],
    group=repeat('A':'E', outer=2),
)
draw(data(df) * visual(Waterfall, show_direction=true) * mapping(:x, :y, color=:group, dodge=:group))

resulted in

ERROR: No aesthetic mapping defined yet for plot type Plot{Makie.waterfall} with scientific eltypes (AlgebraOfGraphics.Continuous(), AlgebraOfGraphics.Continuous()). AlgebraOfGraphics can only use plot types if it is told which attributes and input arguments map to which aesthetics like color, markersize or linewidth for example.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] aesthetic_mapping(::Type{Plot{waterfall}}, ::AlgebraOfGraphics.Continuous, ::AlgebraOfGraphics.Continuous)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/aesthetics.jl:51
  [3] aesthetic_mapping(plottype::Type, attributes::Dictionaries.Dictionary{…}, scitypes::Vector{…})
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/aesthetics.jl:32
  [4] aesthetic_mapping
    @ ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/aesthetics.jl:29 [inlined]
  [5] compute_scale_properties(processedlayers::Vector{ProcessedLayer}, scales::AlgebraOfGraphics.Scales)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/algebra/layers.jl:153
  [6] compute_axes_grid(d::Layer, scales::AlgebraOfGraphics.Scales; axis::Dictionaries.Dictionary{Symbol, Any})
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/algebra/layers.jl:252
  [7] compute_axes_grid
    @ ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/algebra/layers.jl:248 [inlined]
  [8] compute_axes_grid(fig::Figure, d::Layer, scales::AlgebraOfGraphics.Scales; axis::Dictionaries.Dictionary{Symbol, Any})
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/algebra/layers.jl:218
  [9] compute_axes_grid
    @ ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/algebra/layers.jl:215 [inlined]
 [10] #363
    @ ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:20 [inlined]
 [11] update
    @ ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:10 [inlined]
 [12] plot!(fig::Figure, d::Layer, scales::AlgebraOfGraphics.Scales; axis::Dictionaries.Dictionary{Symbol, Any})
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:20
 [13] plot!
    @ ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:16 [inlined]
 [14] (::AlgebraOfGraphics.var"#374#379"{…})(f::Figure)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:162
 [15] update
    @ ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:10 [inlined]
 [16] _draw(d::Layer, scales::AlgebraOfGraphics.Scales; axis::Dictionaries.Dictionary{…}, figure::Dictionaries.Dictionary{…}, facet::Dictionaries.Dictionary{…}, legend::Dictionaries.Dictionary{…}, colorbar::Dictionaries.Dictionary{…})
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:161
 [17] _draw
    @ ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:154 [inlined]
 [18] draw(d::Layer, scales::AlgebraOfGraphics.Scales; axis::@NamedTuple{}, figure::@NamedTuple{}, facet::@NamedTuple{}, legend::@NamedTuple{}, colorbar::@NamedTuple{}, palette::Nothing)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:85
 [19] draw
    @ ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:75 [inlined]
 [20] draw(d::Layer)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/BPWA1/src/draw.jl:75
 [21] top-level scope
    @ REPL[6]:1
Some type information was truncated. Use `show(err)` to see complete types.

Now it produces

waterfall

daschw avatar Jan 10 '25 17:01 daschw