2

我正在制作一个 Pluto 笔记本,在其中使用多个绘图库创建相同的简单绘图。由于绘图库可能会定义具有相同名称的函数,因此我的工作方式如下:

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)

在此处输入图像描述

但是,当我这样做时,我using gadfly在调用时遇到错误AlgebraOfGraphics.draw(),我不清楚为什么。

using Gadfly
AoG.draw(iris_frequency)

MethodError:没有方法匹配大小(::Compose.Property{Compose.FillPrimitive})

最接近的候选人是:

/opt/julia/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/qr.jl:524

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

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

...

轴@abstractarray.jl:89[内联] 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 ntuple@ntuple.jl:19[inlined] mapkeys@entries.jl:75[inlined ] (::AlgebraOfGraphics.var"#118#120"{AlgebraOfGraphics.Layer, Dict{Union{Int64, Symbol}, Any}})(::Tuple{Symbol, Symbol})@processing.jl:99 map@tuple .jl:214[内联] process_mappings(::AlgebraOfGraphics.Layer)@processing.jl:98 to_entry(::AlgebraOfGraphics.Layer)@processing.jl:115 process(::AlgebraOfGraphics.Layer)@processing.jl:122 iterate@generator.jl:47[inlined] collect(::Base.Generator{AlgebraOfGraphics.Layers, typeof(AlgebraOfGraphics.process)})@array.jl:678 map@abstractarray.jl: 2323[内联] 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#91@layers.jl:143[inlined] var"#draw#92"(::NamedTuple{( ), Tuple{}}, ::NamedTuple{(), Tuple{}}, ::NamedTuple{(), Tuple{}}, ::typeof(AlgebraOfGraphics.draw), ::AlgebraOfGraphics.Layer)@layers.jl :150 绘制(::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 ntuple@ntuple.jl:19[inlined] mapkeys@entries.jl:75[inlined] (::AlgebraOfGraphics.var"#118#120"{AlgebraOfGraphics.Layer, Dict{Union{Int64, Symbol }, Any}})(::Tuple{Symbol, Symbol})@processing.jl:99 map@tuple.jl:214[inlined] 顶级作用域@Local: 7[inlined]process_mappings(::AlgebraOfGraphics.Layer )@processing.jl:98 to_entry(::AlgebraOfGraphics.Layer)@processing.jl:115 process(::AlgebraOfGraphics.Layer)@processing.jl:122 iterate@generator.jl:47[inlined] collect(::Base .Generator{AlgebraOfGraphics.Layers, > typeof(AlgebraOfGraphics.process)})@array.jl:678 map@abstractarray.jl: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 #91@layers.jl:143[inlined] var"#draw#92"(::NamedTuple{(), Tuple{}}, ::NamedTuple{(), Tuple{}}, ::NamedTuple{(),元组{}}, ::typeof(AlgebraOfGraphics.draw), ::AlgebraOfGraphics.Layer)@layers.jl:150 draw(::AlgebraOfGraphics.Layer)@layers.jl:150 顶级作用域@Local: 7[inlined ]135 #plot#91@layers.jl: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 顶级作用域@Local: 7[内联]135 #plot#91@layers.jl: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 顶级作用域@Local: 7[内联]

注释掉# using Gadfly并不能解决错误,但这可能是由冥王星引起的。

Pluto 的实时文档识别AoG.draw()AlgebraOfGraphics函数,并typeof(iris_frequency)返回AlgebraOfGraphics.Layer(如您所愿。)

有人知道Gadfly如何导致此错误,以及我如何解决它(除了在不同的笔记本中创建绘图。)

4

0 回答 0