【发布时间】:2019-09-06 18:53:02
【问题描述】:
我想在 for 循环中使用 push!() 来继续两条单独的绘图线。考虑以下示例:
using Plots; gr()
f = x->x*x
g = x->f(x)+.2*randn()
p = plot(-1:.1:0, f, ylim=(-1,2), c=:blue)
s = scatter!(-1:.1:0, g, c=:red)
anim = Animation()
for i=1:10
x = i/10
push!(p, x, f(x))
push!(s, x, g(x)) # without this, f gets continued as expected
frame(anim)
end
gif(anim, "test.gif", fps=2)
为什么push!(p, ...) 和push!(s,...) 都延续蓝线?
如何将分散的数据追加到s?
我知道link 的第二个图通过同时绘制和推送两条线实现了类似的结果,但这种解决方案并不总是实用的,尤其是在更复杂的图中。
【问题讨论】:
标签: animation plot append julia