我想创建多个带有各自图例和共享 y 轴限制的子图。我目前正在通过执行以下操作在循环中创建子图:
fig = Figure()
for i in 1:3
lines(fig[i, 1], rand(10), label="$i")
end
linkyaxes!(fig.content...)
fig
这很好用,但是当接下来尝试向每个子图添加图例时:
fig = Figure()
for i in 1:3
lines(fig[i, 1], rand(10), label="$i")
axislegend()
end
linkyaxes!(fig.content...)
fig
这现在会引发错误:
MethodError: Cannot `convert` an object of type Makie.MakieLayout.Legend to an object of type Makie.MakieLayout.Axis
因为除了之前的原始对象之外,fig.content
现在还包括对象。Makie.MakieLayout.Legend()
Axis
我需要事先过滤掉这些,还是有更好的方法来生成所需的图?