Is there a way to plot a graph in julia while looping?

Consider the following scenario.

     for x in range (1,100)
         for y in range (2,500)
                 #plot(f(x),g(y))
         end
     end

      

where f (x) and g (y) are some custom functions.

The output should be the required points on the plane.

Is there any way in Julia to do what I need?

In general, I can do this

     for x in range (1,100)
         for y in range (2,500)
                 push!(l,f(x))
                 push!(m,g(y))
         end
     end

      

and then plotting from the two lists l, m as x, y respectively.

But now I want to plot points while looping.

+4


source to share


2 answers


This is mostly supported in sections ... see https://github.com/tbreloff/Plots.jl/issues/30 for more details and some examples to use.



+2


source


use the function display

:

for x in 1:100
          p = plot(f(x),g(y))
          display(p)
          sleep(1)
 end

      



(inspired by Andreas Peter on Julia's free channel #helpdesk)

0


source







All Articles