# Julia PyPlot updating vector fields

**URL:** <https://discourse.julialang.org/t/julia-pyplot-updating-vector-fields/115431>\
**Category:** New to Julia\
**Tags:** question, plotting\
**Created:** [June 10, 2024, 2:49pm UTC](https://discourse.julialang.org/t/julia-pyplot-updating-vector-fields/115431 "2024-06-10T14:49:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rzhou-space](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rzhou-space/32/209883_2.png) [@rzhou-space](https://discourse.julialang.org/u/rzhou-space)\
**Post date:** [June 10, 2024, 2:49pm UTC](https://discourse.julialang.org/t/julia-pyplot-updating-vector-fields/115431/1 "2024-06-10T14:49:22Z")

</div>

Hi all,  
i am new to Julia and trying to plot a dynamic vector field generated by PIV analysis. I tried to achieve by ploting the vector fields in a for loop and at each step clear the old vector field and replace it with the new one. However, although adding sleep() to delay the plot, I only get the final vector field without seeing a movie/update.

Does anybody has an idea why this happens and if there is a solution for it? Or other better way to plot dynamic vector fields?

Thanks a lot!

```
using Plots, PyPlot, multi_quickPIV

default_params = multi_quickPIV.setPIVParameters()
IA_size = multi_quickPIV._isize( default_params )[1:2]
IA_step = multi_quickPIV._step( default_params )[1:2]

for t in 1:2
    PyPlot.clf()

    img1 = Float64.(Gray.(l_data[:, :, t]))
    img2 = Float64.(Gray.(l_data[:, :, t+1]))

    VF, SN = multi_quickPIV.PIV(img1, img2)

    U = VF[1, :, :]
    V = VF[2, :, :]

    xgrid = [(x-1)*IA_step[2] + div(IA_size[2],2) for y in 1:size(U,1), x in 1:size(U,2) ]; 
    ygrid = [(y-1)*IA_step[1] + div(IA_size[1],2) for y in 1:size(U,1), x in 1:size(U,2) ]; 

    PyPlot.quiver( xgrid, ygrid, V, -1 .* U )
    PyPlot.sleep(0.1);

end

```
