julia - 将绘图存储在数组中

标签 julia plots.jl

我正在尝试在子图中绘制数据帧不同列的直方图。

plt_count = 1
for i = names(abalone)[2:end]
    p[plt_count]=histogram(abalone[:,i])
    plt_count += 1
end
plot(p, layout=(3,3), legend=false)

这是我尝试过的。但我无法为数组 p 提供正确的定义。如何定义p?

对代码的改进也会有所帮助。

最佳答案

如果不关心类型稳定性,可以制作Any类型数组。

ps = Array{Any}(nothing, 3)
ps[1] = plot([2,3,4])
ps[2] = plot([1,5])
ps[3] = plot([10,5,1,0])

@show typeof(ps)
plot(ps..., layout=(3,1))

如果您想专门创建一个Plot类型的数组,一种方法是用虚拟图初始化一个数组,然后再替换。

ps = repeat([plot(1)], 3)
ps[1] = plot([2,3,4])
ps[2] = plot([1,5])
ps[3] = plot([10,5,1,0])

@show typeof(ps)
plot(ps..., layout=(3,1))

关于julia - 将绘图存储在数组中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55160361/

相关文章:

julia - Julia 复合类型中的参数数组长度

python - BigInts 在 Julia 中似乎很慢

julia - 在 Julia 中动画化 ODE 的解决方案

julia - 如何设置 Plots 的默认属性?

julia - Plots.jl - 将表面颜色映射到矩阵

Julia : How to permute randomly a vector in julia?

julia - 自定义使用括号,如 NamedTuple

python-3.x - Julia UndefVarError

julia - Julia 中的 3D 曲面图

matrix - 如何将 Julia 图(通过 Plots.jl)转换为 Matrix{RGB{N0f8}}