Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing aesthetic mapping for Hist #521

Closed
okatsn opened this issue Aug 16, 2024 · 0 comments · Fixed by #522
Closed

Missing aesthetic mapping for Hist #521

okatsn opened this issue Aug 16, 2024 · 0 comments · Fixed by #522

Comments

@okatsn
Copy link

okatsn commented Aug 16, 2024

Bug description

Following the issue #520,
using visual(Hist) encounters similar "No aesthetic mapping ..." Error using AoG 0.8.0.

Steps to reproduce

using CairoMakie, AlgebraOfGraphics
    data((; v = randn(1000))) * mapping(:v) * visual(Hist) |> draw

Error reporting

ERROR: No aesthetic mapping defined yet for plot type Plot{Makie.hist} with scientific eltypes (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(T::Type{Plot{Makie.hist}}, scitypes::AlgebraOfGraphics.Continuous)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/aesthetics.jl:50
  [3] aesthetic_mapping(plottype::Type, attributes::Dictionaries.Dictionary{…}, scitypes::Vector{…})
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/aesthetics.jl:31
  [4] aesthetic_mapping
    @ ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/aesthetics.jl:28 [inlined]
  [5] compute_scale_properties(processedlayers::Vector{ProcessedLayer}, scales::AlgebraOfGraphics.Scales)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/algebra/layers.jl:140
  [6] compute_axes_grid(d::Layer, scales::AlgebraOfGraphics.Scales; axis::Dictionaries.Dictionary{Symbol, Any})
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/algebra/layers.jl:237
  [7] compute_axes_grid
    @ ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/algebra/layers.jl:233 [inlined]
  [8] compute_axes_grid(fig::Figure, d::Layer, scales::AlgebraOfGraphics.Scales; axis::Dictionaries.Dictionary{Symbol, Any})
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/algebra/layers.jl:205
  [9] compute_axes_grid
    @ ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/algebra/layers.jl:202 [inlined]
 [10] #338
    @ ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/draw.jl:20 [inlined]
 [11] update
    @ ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/draw.jl:10 [inlined]
 [12] plot!(fig::Figure, d::Layer, scales::AlgebraOfGraphics.Scales; axis::Dictionaries.Dictionary{Symbol, Any})
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/draw.jl:20
 [13] plot!
    @ ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/draw.jl:16 [inlined]
 [14] (::AlgebraOfGraphics.var"#343#344"{…})(f::Figure)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/draw.jl:64
 [15] update
    @ ~/.julia/packages/AlgebraOfGraphics/5jZeR/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/5jZeR/src/draw.jl:63
 [17] _draw
    @ ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/draw.jl:60 [inlined]
 [18] draw(d::Layer, scales::AlgebraOfGraphics.Scales; axis::@NamedTuple{}, figure::@NamedTuple{}, facet::@NamedTuple{}, legend::@NamedTuple{}, colorbar::@NamedTuple{}, palette::Nothing)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/draw.jl:57
 [19] draw
    @ ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/draw.jl:47 [inlined]
 [20] draw(d::Layer)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/draw.jl:47
 [21] |>(x::Layer, f::typeof(draw))
    @ Base ./operators.jl:917

Version info

Julia Version 1.10.4
[cbdf2221] AlgebraOfGraphics v0.8.0
[13f3f980] CairoMakie v0.12.6
[ee78f7c6] Makie v0.21.6

Solution (?)

Overload the aesthetic_mapping function as below then data((; v = randn(1000))) * mapping(:v) * visual(Hist) |> draw works as expected; however, I'm not sure this is the general solution for Makie.hist to work with the newer AoG.

function AlgebraOfGraphics.aesthetic_mapping(::Type{Hist}, ::AlgebraOfGraphics.Normal)
    AlgebraOfGraphics.dictionary([
        1 => AlgebraOfGraphics.AesX,
        :color => AlgebraOfGraphics.AesColor,
    ])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant