Compose.jl
Compose.jl copied to clipboard
using Gadfly causes Method error in AlgebraOfGraphics.draw()
I'm not really sure if this is a Gadfly.jl/Compose.jl or a AlgebraOfGraphics.jl issue so I thought I make an issue at both repos. here
I was making a notebook with plots from multiple packages (to compare them) when I found that using Gadfly introduces an error when calling AlgebraOfGraphics.draw(). The error message mentions some Compose.jl object, but the draw method I call and the AlgebraOfGraphics.Layer I call it on don't seem to be directly affected.
this works fine
julia> using AlgebraOfGraphics, RDatasets, CairoMakie
julia> const AoG = AlgebraOfGraphics
julia> iris = dataset("datasets", "iris")
julia> iris_frequency = AoG.data(iris) *
AoG.mapping(:PetalLength, :PetalWidth) *
AoG.mapping(color = :Species)
julia> fg1 = AoG.draw(iris_frequency)
julia> save("figure.png", fg1, px_per_unit = 3)
but using Gadfly introduces an error
julia> using Gadfly
# now throws an error
julia> fg2 = AoG.draw(iris_frequency)
ERROR: MethodError: no method matching size(::Compose.Property{Compose.FillPrimitive})
Closest candidates are:
size(::Union{LinearAlgebra.QR, LinearAlgebra.QRCompactWY, LinearAlgebra.QRPivoted}) at /opt/julia/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/qr.jl:524
size(::Union{LinearAlgebra.QR, LinearAlgebra.QRCompactWY, LinearAlgebra.QRPivoted}, ::Integer) at /opt/julia/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/qr.jl:523
size(::Union{LinearAlgebra.Cholesky, LinearAlgebra.CholeskyPivoted}) at /opt/julia/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/cholesky.jl:442
...
Stacktrace:
[1] axes
@ ./abstractarray.jl:89 [inlined]
[2] combine_axes(::Compose.Property{Compose.FillPrimitive}, ::Compose.Property{Compose.FillPrimitive}, ::Compose.Property{Compose.FillPrimitive})
@ Base.Broadcast ./broadcast.jl:483
[3] shape(x::AlgebraOfGraphics.Layer)
@ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/4qspg/src/algebra/processing.jl:17
[4] getlabeledarray(layer::AlgebraOfGraphics.Layer, s::Symbol)
@ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/4qspg/src/algebra/processing.jl:72
[5] (::AlgebraOfGraphics.var"#119#121"{Tuple{Symbol, Symbol}, AlgebraOfGraphics.Layer, Dict{Union{Int64, Symbol}, Any}})(key::Int64)
@ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/4qspg/src/algebra/processing.jl:100
[6] ntuple
@ ./ntuple.jl:19 [inlined]
[7] mapkeys
@ ~/.julia/packages/AlgebraOfGraphics/4qspg/src/entries.jl:75 [inlined]
[8] (::AlgebraOfGraphics.var"#118#120"{AlgebraOfGraphics.Layer, Dict{Union{Int64, Symbol}, Any}})(tup::Tuple{Symbol, Symbol})
@ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/4qspg/src/algebra/processing.jl:99
[9] map
@ ./tuple.jl:214 [inlined]
[10] process_mappings(layer::AlgebraOfGraphics.Layer)
@ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/4qspg/src/algebra/processing.jl:98
[11] to_entry(layer::AlgebraOfGraphics.Layer)
@ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/4qspg/src/algebra/processing.jl:115
[12] process(layer::AlgebraOfGraphics.Layer)
@ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/4qspg/src/algebra/processing.jl:122
[13] iterate
@ ./generator.jl:47 [inlined]
[14] collect(itr::Base.Generator{AlgebraOfGraphics.Layers, typeof(AlgebraOfGraphics.process)})
@ Base ./array.jl:678
[15] map
@ ./abstractarray.jl:2323 [inlined]
[16] compute_axes_grid(fig::Figure, s::AlgebraOfGraphics.Layer; axis::NamedTuple{(), Tuple{}}, palettes::NamedTuple{(), Tuple{}})
@ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/4qspg/src/algebra/layers.jl:70
[17] plot!(fig::Figure, s::AlgebraOfGraphics.Layer; axis::NamedTuple{(), Tuple{}}, palettes::NamedTuple{(), Tuple{}})
@ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/4qspg/src/algebra/layers.jl:135
[18] #plot#91
@ ~/.julia/packages/AlgebraOfGraphics/4qspg/src/algebra/layers.jl:143 [inlined]
[19] draw(s::AlgebraOfGraphics.Layer; axis::NamedTuple{(), Tuple{}}, figure::NamedTuple{(), Tuple{}}, palettes::NamedTuple{(), Tuple{}})
@ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/4qspg/src/algebra/layers.jl:150
[20] draw(s::AlgebraOfGraphics.Layer)
@ AlgebraOfGraphics ~/.julia/packages/AlgebraOfGraphics/4qspg/src/algebra/layers.jl:150
[21] top-level scope
@ REPL[14]:1
I checked that the following returns the same before and after using Gadfly:
julia> typeof(iris_frequency)
AlgebraOfGraphics.Layer
help?> AoG.draw
No documentation found.
AlgebraOfGraphics.draw is a Function.
# 1 method for generic function "draw":
[1] draw(s::Union{AlgebraOfGraphics.Layer, AlgebraOfGraphics.Layers}; axis, figure, palettes) in AlgebraOfGraphics at /home/me/.julia/packages/AlgebraOfGraphics/4qspg/src/algebra/layers.jl:148
(juliaplotting) pkg> status
Status `~/Repos/juliaplotting/Project.toml`
[cbdf2221] AlgebraOfGraphics v0.4.5
[13f3f980] CairoMakie v0.5.10
...
[c91e804a] Gadfly v1.3.3
...
[ce6b1742] RDatasets v0.7.5
This is caused by https://github.com/GiovineItalia/Compose.jl/blob/da671cd35805bfbd9dc7a433830b4a8d608fe93a/src/property.jl#L71 which commits type piracy (see linked issue for details).
Thanks, for figuring that out! I couldn't find it but now it makes sense.