hanugm
hanugm

Reputation: 1387

Is there a way to plot graph in julia while executing loops?

Let us 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 user defined functions.

The output must be the desired points on plane.

Is there any way in julia to do like what I need ?

In general I can do like 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 axes respectively.

But now I want to plot points while executing loop.

Upvotes: 5

Views: 11272

Answers (2)

Vass
Vass

Reputation: 2820

use the display function:

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

(inspired by Andreas Peter on the Julia slack #helpdesk channel)

Upvotes: 2

Tom Breloff
Tom Breloff

Reputation: 1802

This is mostly supported in Plots... see https://github.com/tbreloff/Plots.jl/issues/30 for a little more information and some example usage.

Upvotes: 4

Related Questions