gpt4 book ai didi

julia - 使用 Plots.jl 将一组图绘制为子图

转载 作者:行者123 更新时间:2023-12-04 08:10:22 24 4
gpt4 key购买 nike

此线程的延续:How to create an arbitrary number of subplots in Julia Plots

当我尝试过

using Plots
plot_array = Any[]
for i in 1:5
push!(plot_array, plot(rand(10))) # make a plot and add it to the plot_array
end
plot(plot_array)

我收到错误:

MethodError: no method matching Plots.Plot{Plots.PlotlyBackend}(::Char, ::Char, ::Char, ::Char, ...) 
Closest candidates are: Plots.Plot{Plots.PlotlyBackend}(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any)

我错过了什么?

最佳答案

您需要使用 ... 在最后一个 plot 调用中“展开”子图数组:

using Plots
plot_array = []
for i in 1:5
push!(plot_array, plot(rand(10)))
end
plot(plot_array...) # note the "..."

会产生类似的东西

enter image description here

关于julia - 使用 Plots.jl 将一组图绘制为子图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66001062/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com