相关疑难解决方法(0)

如何在 Julia Plots 中创建任意数量的子图

我想使用 Breloff 的 Julia Plots从多维数组中制作一组子。这个 plot 函数接受一个 varargs 输入并将它们变成子图,但我似乎无法正确输入我的数组,并且可能忽略了一些简单的东西。例如使用数组a

a = randn(5,5,8)
a = a.-mean(a)
a = a./maximum(extrema(a))
Run Code Online (Sandbox Code Playgroud)

如果我想将一些 5x5 切片绘制为热图,我可以这样做:

plot(heatmap(a[:,:,1], aspect_ratio=:equal, clims=(-1,1), title=string(1)), 
heatmap(a[:,:,2], aspect_ratio=:equal, clims=(-1,1), title=string(2)),
heatmap(a[:,:,3], aspect_ratio=:equal, clims=(-1,1), title=string(3)))
Run Code Online (Sandbox Code Playgroud)

它产生:

3个热图数组

但是如果我想完成所有八个(或我的目标是一个可变数字),我不能让它与循环或 splat 一起工作。我尝试后者创建一个元组,但出现错误:

plot(tuple([heatmap(a[:,:,i], aspect_ratio=:equal, clims=(-1,1)) for i in 1:8]...))

LoadError: MethodError: Cannot `convert` an object of type String to an object of type MethodError
This may have arisen from a call to the constructor MethodError(...),
since type constructors fall back …
Run Code Online (Sandbox Code Playgroud)

heatmap subplot julia plots.jl

3
推荐指数
1
解决办法
2083
查看次数

标签 统计

heatmap ×1

julia ×1

plots.jl ×1

subplot ×1