Jonas
Jonas

Reputation: 1529

using Gadlfy.jl and AlgebraOfGraphics.jl within same notebook causes MethodError

I am making a Pluto notebook where I create the same simple plot with several plotting libraries. Since plotting libraries might define functions with the same name I work like this:

using AlgebraOfGraphics, RDatasets, CairoMakie
const AoG = AlgebraOfGraphics

iris = dataset("datasets", "iris")

iris_frequency = AoG.data(iris) *
    AoG.mapping(:PetalLength, :PetalWidth) *
    AoG.mapping(color = :Species) 
AoG.draw(iris_frequency)

enter image description here

However, when I do using gadfly I get an error when calling AlgebraOfGraphics.draw(), and it is not clear to me why.

using Gadfly
AoG.draw(iris_frequency)

MethodError: no method matching size(::Compose.Property{Compose.FillPrimitive})

Closest candidates are:

size(!Matched::Union{LinearAlgebra.QR, LinearAlgebra.QRCompactWY, LinearAlgebra.QRPivoted}) at /opt/julia/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/qr.jl:524

size(!Matched::Union{LinearAlgebra.QR, LinearAlgebra.QRCompactWY, LinearAlgebra.QRPivoted}, !Matched::Integer) at /opt/julia/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/qr.jl:523

size(!Matched::Union{LinearAlgebra.Cholesky, LinearAlgebra.CholeskyPivoted}) at /opt/julia/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/cholesky.jl:442

...

axes @abstractarray.jl:89[inlined] combine_axes(::Compose.Property{Compose.FillPrimitive}, ::Compose.Property{Compose.FillPrimitive}, ::Compose.Property{Compose.FillPrimitive})@broadcast.jl:483 shape(::AlgebraOfGraphics.Layer)@processing.jl:17 getlabeledarray(::AlgebraOfGraphics.Layer, ::Symbol)@processing.jl:72 (::AlgebraOfGraphics.var"#119#121"{Tuple{Symbol, Symbol}, AlgebraOfGraphics.Layer, Dict{Union{Int64, Symbol}, Any}})(::Int64)@processing.jl:100 [email protected]:19[inlined] [email protected]:75[inlined] (::AlgebraOfGraphics.var"#118#120"{AlgebraOfGraphics.Layer, Dict{Union{Int64, Symbol}, Any}})(::Tuple{Symbol, Symbol})@processing.jl:99 [email protected]:214[inlined] process_mappings(::AlgebraOfGraphics.Layer)@processing.jl:98 to_entry(::AlgebraOfGraphics.Layer)@processing.jl:115 process(::AlgebraOfGraphics.Layer)@processing.jl:122 [email protected]:47[inlined] collect(::Base.Generator{AlgebraOfGraphics.Layers, typeof(AlgebraOfGraphics.process)})@array.jl:678 [email protected]:2323[inlined] var"#compute_axes_grid#81"(::NamedTuple{(), Tuple{}}, ::NamedTuple{(), Tuple{}}, ::typeof(AlgebraOfGraphics.compute_axes_grid), ::Makie.Figure, ::AlgebraOfGraphics.Layer)@layers.jl:70 var"#plot!#90"(::NamedTuple{(), Tuple{}}, ::NamedTuple{(), Tuple{}}, ::typeof(Makie.plot!), ::Makie.Figure, ::AlgebraOfGraphics.Layer)@layers.jl:135 #plot#[email protected]:143[inlined] var"#draw#92"(::NamedTuple{(), Tuple{}}, ::NamedTuple{(), Tuple{}}, ::NamedTuple{(), Tuple{}}, ::typeof(AlgebraOfGraphics.draw), ::AlgebraOfGraphics.Layer)@layers.jl:150 draw(::AlgebraOfGraphics.Layer)@layers.jl:150 getlabeledarray(::AlgebraOfGraphics.Layer, ::Symbol)@processing.jl:72 (::AlgebraOfGraphics.var"#119#121"{Tuple{Symbol, Symbol}, AlgebraOfGraphics.Layer, Dict{Union{Int64, Symbol}, Any}})(::Int64)@processing.jl:100 [email protected]:19[inlined] [email protected]:75[inlined] (::AlgebraOfGraphics.var"#118#120"{AlgebraOfGraphics.Layer, Dict{Union{Int64, Symbol}, Any}})(::Tuple{Symbol, Symbol})@processing.jl:99 [email protected]:214[inlined] top-level scope@Local: 7[inlined]process_mappings(::AlgebraOfGraphics.Layer)@processing.jl:98 to_entry(::AlgebraOfGraphics.Layer)@processing.jl:115 process(::AlgebraOfGraphics.Layer)@processing.jl:122 [email protected]:47[inlined] collect(::Base.Generator{AlgebraOfGraphics.Layers, > typeof(AlgebraOfGraphics.process)})@array.jl:678 [email protected]:2323[inlined] var"#compute_axes_grid#81"(::NamedTuple{(), Tuple{}}, ::NamedTuple{(), Tuple{}}, ::typeof(AlgebraOfGraphics.compute_axes_grid), ::Makie.Figure, ::AlgebraOfGraphics.Layer)@layers.jl:70 var"#plot!#90"(::NamedTuple{(), Tuple{}}, ::NamedTuple{(), Tuple{}}, ::typeof(Makie.plot!), ::Makie.Figure, ::AlgebraOfGraphics.Layer)@layers.jl:135 #plot#[email protected]:143[inlined] var"#draw#92"(::NamedTuple{(), Tuple{}}, ::NamedTuple{(), Tuple{}}, ::NamedTuple{(), Tuple{}}, ::typeof(AlgebraOfGraphics.draw), ::AlgebraOfGraphics.Layer)@layers.jl:150 draw(::AlgebraOfGraphics.Layer)@layers.jl:150 top-level scope@Local: 7[inlined]

Commenting out # using Gadfly doesn't resolve the error, but that might be a caused by Pluto.

Pluto's live docs recognizes AoG.draw() as an AlgebraOfGraphics function, and typeof(iris_frequency) returns AlgebraOfGraphics.Layer (What you would expect.)

Does somebody have any idea how Gadfly can cause this error, and how I can solve it (apart from creating the plots in different notebooks.)

Upvotes: 3

Views: 106

Answers (0)

Related Questions