如何解决在同一笔记本中使用 Gadlfy.jl 和 AlgebraOfGraphics.jl 会导致 MethodError
我正在制作一个 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})
最接近的候选人是:
size(!Matched::Union{Linearalgebra.QR,Linearalgebra.QRCompactWY,Linearalgebra.QRPiVoted}) 在 /opt/julia/usr/share/julia/stdlib/v1.6/Linearalgebra/src/qr.jl: 524
size(!Matched::Union{Linearalgebra.QR,Linearalgebra.QRPiVoted},!Matched::Integer) 在 /opt/julia/usr/share/julia/stdlib/v1.6/Linearalgebra/ src/qr.jl:523
size(!Matched::Union{Linearalgebra.Cholesky,Linearalgebra.CholeskyPiVoted}) 在 /opt/julia/usr/share/julia/stdlib/v1.6/Linearalgebra/src/cholesky.jl:442
...
轴@abstractarray.jl:89[内联] combine_axes(::Compose.Property{Compose.FillPrimitive},::Compose.Property{Compose.FillPrimitive},::Compose.Property{Compose.FillPrimitive})@broadcast.jl:483 形状(::AlgebraOfGraphics.Layer)@processing.jl:17 getlabeledarray(::AlgebraOfGraphics.Layer,::Symbol)@processing.jl:72 (::AlgebraOfGraphics.var"#119#121"{Tuple{Symbol,Symbol},AlgebraOfGraphics.Layer,Dict{Union{Int64,Any}})(::Int64)@processing.jl:100 ntuple@ntuple.jl:19[内联] mapkeys@entries.jl:75[内联] (::AlgebraOfGraphics.var"#118#120"{AlgebraOfGraphics.Layer,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 进程(::AlgebraOfGraphics.Layer)@processing.jl:122 iterate@generator.jl:47[内联] collect(::Base.Generator{AlgebraOfGraphics.Layers,typeof(AlgebraOfGraphics.process)})@array.jl:678 map@abstractarray.jl:2323[内联] var"#compute_axes_grid#81"(::NamedTuple{(),Tuple{}},::NamedTuple{(),::typeof(AlgebraOfGraphics.compute_axes_grid),::Makie.figure,::AlgebraOfGraphics .Layer)@layers.jl:70 var"#plot!#90"(::NamedTuple{(),::typeof(Makie.plot!),: :AlgebraOfGraphics.Layer)@layers.jl:135 #plot#91@layers.jl:143[内联] var"#draw#92"(::NamedTuple{(),::typeof(AlgebraOfGraphics. draw),::AlgebraOfGraphics.Layer)@layers.jl:150 draw(::AlgebraOfGraphics.Layer)@layers.jl:150 getlabeledarray(::AlgebraOfGraphics.Layer,Symbol})@processing.jl:99 map@tuple.jl:214[内联] 顶级范围@Local:7[内联]process_mappings(::AlgebraOfGraphics.Layer)@processing.jl:98 to_entry(::AlgebraOfGraphics.Layer)@processing.jl:115 进程(::AlgebraOfGraphics.Layer)@processing.jl:122 iterate@generator.jl:47[内联] collect(::Base.Generator{AlgebraOfGraphics.Layers,> typeof(AlgebraOfGraphics.process)})@array.jl:678 map@abstractarray.jl:2323[内联] var"#compute_axes_grid#81"(::NamedTuple{(),::AlgebraOfGraphics.Layer)@layers.jl:150 draw(::AlgebraOfGraphics.Layer)@layers.jl:150 顶级范围@Local: 7[inlined]
注释掉 # using Gadfly
并不能解决错误,但这可能是由 Pluto 引起的。
Pluto 的实时文档将 AoG.draw()
识别为 AlgebraOfGraphics 函数,并且 typeof(iris_frequency)
返回 AlgebraOfGraphics.Layer
(您所期望的。)
有人知道 Gadfly 如何导致此错误,以及我如何解决它(除了在不同的笔记本中创建绘图。)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。