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 Density and ECDFPlot #520

Closed
sethaxen opened this issue Aug 11, 2024 · 0 comments
Closed

Missing aesthetic mapping for Density and ECDFPlot #520

sethaxen opened this issue Aug 11, 2024 · 0 comments

Comments

@sethaxen
Copy link

Problem description

Since #505, using visual(Density) or visual(ECDFPlot) no longer works, but it used to work using AoG v0.6.20:

julia> using AlgebraOfGraphics, CairoMakie

julia> layers = data((; x=randn(10))) * mapping(:x);

julia> draw(layers * visual(Lines));  # fine

julia> draw(layers * visual(ECDFPlot))  # errors
ERROR: No aesthetic mapping defined yet for plot type Plot{Makie.ecdfplot} 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.ecdfplot}}, 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] top-level scope
    @ REPL[12]:1
Some type information was truncated. Use `show(err)` to see complete types.

julia> draw(layers * visual(Density));  # errors, same as above
...

Proposed solution

I thought just adding the following aesthetic_mapping overloads would work. This worked for Density but not for ECDFPlot. If we roll back CairoMakie to v0.11 it also works for ECDFPlot:

julia> using AlgebraOfGraphics: dictionary, Normal, AesX, AesColor, AesLineStyle

julia> function AlgebraOfGraphics.aesthetic_mapping(::Type{ECDFPlot}, ::Normal)
    dictionary([
        1 => AesX,
        :color => AesColor,
        :linestyle => AesLineStyle,
    ])
end;

julia> function AlgebraOfGraphics.aesthetic_mapping(::Type{Density}, ::Normal)
    dictionary([
        1 => AesX,
        :color => AesColor,
        :linestyle => AesLineStyle,
    ])
end;

julia> draw(layers * visual(Density));  # works

julia> draw(layers * visual(ECDFPlot))  # errors
ERROR: Can't get property cycle on PlotList with multiple plots.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] getproperty(pl::Plot{Makie.plotlist, Tuple{PlotSpec}}, property::Symbol)
    @ Makie ~/.julia/packages/Makie/rEu75/src/specapi.jl:366
  [3] add_cycle_attribute!(plot::Plot{Makie.plotlist, Tuple{PlotSpec}}, scene::Scene)
    @ Makie ~/.julia/packages/Makie/rEu75/src/interfaces.jl:3
  [4] calculated_attributes!(::Type{Plot{Makie.plotlist}}, plot::Plot{Makie.plotlist, Tuple{PlotSpec}})
    @ Makie ~/.julia/packages/Makie/rEu75/src/interfaces.jl:21
  [5] connect_plot!(parent::Scene, plot::Plot{Makie.plotlist, Tuple{PlotSpec}})
    @ Makie ~/.julia/packages/Makie/rEu75/src/interfaces.jl:378
  [6] plot!
    @ ~/.julia/packages/Makie/rEu75/src/interfaces.jl:389 [inlined]
  [7] plot!(ax::Axis, plot::Plot{Makie.plotlist, Tuple{PlotSpec}})
    @ Makie ~/.julia/packages/Makie/rEu75/src/figureplotting.jl:412
  [8] plot!(ae::AxisEntries)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/entries.jl:82
  [9] foreach(f::typeof(plot!), itr::Matrix{AxisEntries})
    @ Base ./abstractarray.jl:3097
 [10] plot!(fig::Figure, d::Layer, scales::AlgebraOfGraphics.Scales; axis::Dictionaries.Dictionary{Symbol, Any})
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/draw.jl:21
 [11] plot!
    @ ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/draw.jl:16 [inlined]
 [12] (::AlgebraOfGraphics.var"#343#344"{…})(f::Figure)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/draw.jl:64
 [13] update
    @ ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/draw.jl:10 [inlined]
 [14] _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
 [15] _draw
    @ ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/draw.jl:60 [inlined]
 [16] 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
 [17] draw
    @ ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/draw.jl:47 [inlined]
 [18] draw(d::Layer)
    @ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/5jZeR/src/draw.jl:47
 [19] top-level scope
    @ REPL[17]:1
Some type information was truncated. Use `show(err)` to see complete types.

Environment

julia> using Pkg; Pkg.status()
Status `/tmp/jl_Z7XUYH/Project.toml`
  [cbdf2221] AlgebraOfGraphics v0.8.0
  [13f3f980] CairoMakie v0.12.5

julia> versioninfo()
Julia Version 1.10.4
Commit 48d4fd48430 (2024-06-04 10:41 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, tigerlake)
Threads: 8 default, 0 interactive, 4 GC (on 8 virtual cores)
Environment:
  JULIA_NUM_THREADS = auto
  JULIA_EDITOR = code
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

No branches or pull requests

2 participants