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.
A Plot is only displayed when returned (a semicolon will suppress the return), or if explicitly displayed with display(plt) , gui() , or by adding show = true to your plot command.
It is caused by Julia compiling the needed functions on the fly (precompilation only does half of all the compile work). If you search for “time to first plot” you will find a large amount of reading material…
3.2. Plots plots functions by creating a large number of paired points ( x , f ( x ) ) ; it then plots these points; and, finally, connects the points with line segments.
This is mostly supported in Plots... see https://github.com/tbreloff/Plots.jl/issues/30 for a little more information and some example usage.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With