I try to reproduce the following two examples in Julia 1.0.2,:
using Plots
anim = Animation()
p = plot([sin,cos], 0, π, size=(300,300))
scatter!([0], [sin,cos])
for i in 0:0.1:π
p[3] = [i], [sin(i)]
p[4] = [i], [cos(i)]
frame(anim)
end
gif(anim)
using Plots
pyplot(size=(300,200))
p = plot([sin,cos], 0, π, lab=[:sin :cos])
scatter!(1, lab="")
anim = @animate for x in 0:0.1:π
p[3] = [x,x], [sin(x),cos(x)]
end
gif(anim)
Previous stable release (v0.7.0)
Julia v0.7.0 is a transitional release, intended to aid the transition from Julia v0.6, to Julia v1.0.
Does this mean that I should have version 0.7.0 installed and run examples from previous versions?
How to proceed, please. I’m introducing myself to Julia, and my scrips sources are the ones I find on the Web. And at times I do not know if it’s a problem with the installation of Julia or scrips made in previous versions.
ERROR: LoadError: MethodError: no method matching sin(::StepRangeLen{Float64,Base.TwicePrecision{Flo
at64},Base.TwicePrecision{Float64}})
Closest candidates are:
sin(::Float16) at math.jl:1018
sin(::Complex{Float16}) at math.jl:1019
sin(::Missing) at math.jl:1070
…
Stacktrace:
[1] top-level scope at none:0
in expression starting at C:\Users\hermesr\Documents\Julia software\Julia Scripts\It must be updated
_plot6:6
ERROR: LoadError: ArgumentError: Package Iterators not found in current path:
- Run `import Pkg; Pkg.add("Iterators")` to install the Iterators package.
Stacktrace:
[1] require(::Module, ::Symbol) at .\loading.jl:823
in expression starting at untitled-a9ed118462e1117562543b47d8c6e8d1:1
(v1.0) pkg> add Iterators
Updating registry at `C:\Users\hermesr\.julia\registries\General`
Updating git-repo `https://github.com/JuliaRegistries/General.git`
┌ Warning: Some registries failed to update:
│ — C:\Users\hermesr\.julia\registries\General — failed to fetch from repo
└ @ Pkg.API C:\cygwin\home\Administrator\buildbot\worker\package_win32\build\usr\share\julia\stdlib\
v1.0\Pkg\src\API.jl:157
Resolving package versions...
ERROR: Unsatisfiable requirements detected for package Iterators [a4bce56a]:
Iterators [a4bce56a] log:
├─possible versions are: [0.1.0-0.1.10, 0.2.0, 0.3.0-0.3.1] or uninstalled
├─restricted to versions * by an explicit requirement, leaving only versions [0.1.0-0.1.10, 0.2.0,
0.3.0-0.3.1]
└─restricted by julia compatibility requirements to versions: uninstalled — no versions left
(v1.0) pkg>
using Plots
using Base.Iterators
itr = repeatedly(()->rand(10), 20)
animate(itr, ylims=(0,1), c=:red, fps=5)
ERROR: LoadError: UndefVarError: repeatedly not defined
Stacktrace:
[1] top-level scope at none:0
in expression starting at untitled-a9ed118462e1117562543b47d8c6e8d1:3
So I update the code lines of the example. Is Correto?
using Plots
using .Iterators
itr = repeated(()->rand(10), 20)
animate(itr, ylims=(0,1), c=:red, fps=5)
Since I get the following errors
ERROR: LoadError: getfield(Main, Symbol("##13#14"))() is not a Function, or is not defined at any of
the values [-5.0, -1.0, 0.0, 0.01]
Stacktrace:
[1] tryrange(::getfield(Main, Symbol("##13#14")), ::Array{Float64,1}) at C:\Users\hermesr\.julia\pa
ckages\Plots\rmogG\src\series.jl:412
[2] macro expansion at C:\Users\hermesr\.julia\packages\Plots\rmogG\src\series.jl:389 [inlined]
[3] apply_recipe(::Dict{Symbol,Any}, ::getfield(Main, Symbol("##13#14"))) at C:\Users\hermesr\.juli
a\packages\RecipesBase\Uz5AO\src\RecipesBase.jl:275
[4] _process_userrecipes(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{getfield(Main,
Symbol("##13#14"))}) at C:\Users\hermesr\.julia\packages\Plots\rmogG\src\pipeline.jl:83
[5] macro expansion at .\logging.jl:305 [inlined]
[6] _plot!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{getfield(Main, Symbol("##13#1
4"))}) at C:\Users\hermesr\.julia\packages\Plots\rmogG\src\plot.jl:171
[7] #plot#132(::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol},NamedTuple{(:ylims, :c),Tuple{
Tuple{Int32,Int32},Symbol}}}, ::Function, ::Function) at C:\Users\hermesr\.julia\packages\Plots\rmog
G\src\plot.jl:57
[8] (::getfield(RecipesBase, Symbol("#kw##plot")))(::NamedTuple{(:ylims, :c),Tuple{Tuple{Int32,Int3
2},Symbol}}, ::typeof(plot), ::Function) at .\none:0
[9] #animate#223(::Base.Iterators.Pairs{Symbol,Int32,Tuple{Symbol,Symbol},NamedTuple{(:fps, :loop),
Tuple{Int32,Int32}}}, ::Function, ::Plots.FrameIterator, ::String) at C:\Users\hermesr\.julia\packag
es\Plots\rmogG\src\animation.jl:42
[10] #animate at .\none:0 [inlined]
[11] #animate#224 at C:\Users\hermesr\.julia\packages\Plots\rmogG\src\animation.jl:51 [inlined]
[12] #animate at .\none:0 [inlined] (repeats 2 times)
[13] top-level scope at none:0
in expression starting at untitled-a9ed118462e1117562543b47d8c6e8d1:4
julia>
itr = zip(rand(10))
animate(zip)
> No user recipe defined for float64
itr = zip(rand([1:4], 10))
animate(zip)
> Couldn't spawn `ffmpeg ... ` no such file or directory
I don’t know what the second achieves. Anyway, the error is because you don’t have ffmpeg installed.
I’ll have to look into the recommended suggestion for repeatedly tonight.
using Plots
using Base.Iterators
#itr = repeated(()->rand(10), 20)
#animate(itr, ylims=(0,1), c=:red, fps=5)
itr = zip(rand(10))
animate(zip)
Error evaluating It must be updated_plot8
LoadError: MethodError: no method matching iterate(::typeof(zip))
Closest candidates are:
iterate(!Matched::Core.SimpleVector) at essentials.jl:589
iterate(!Matched::Core.SimpleVector, !Matched::Any) at essentials.jl:589
iterate(!Matched::ExponentialBackOff) at error.jl:171
...
in expression starting at C:\Users\hermesr\Documents\Julia software\Julia Scripts\It must be updated_plot8:6
iterate(::Base.Iterators.Enumerate{typeof(zip)}, ::Tuple{Int32}) at iterators.jl:139
iterate at iterators.jl:138 [inlined]
#animate#223(::Base.Iterators.Pairs{Symbol,Int32,Tuple{Symbol,Symbol},NamedTuple{(:fps, :loop),Tuple{Int32,Int32}}}, ::Function, ::Plots.FrameIterator, ::String) at animation.jl:40
#animate at none:0 [inlined]
#animate#224 at animation.jl:51 [inlined]
animate at animation.jl:51 [inlined]
animate(::Function) at animation.jl:51
top-level scope at none:0
using Plots
using Base.Iterators
#itr = repeated(()->rand(10), 20)
#animate(itr, ylims=(0,1), c=:red, fps=5)
##
#itr = zip(rand(10))
#animate(zip)
###
itr = repeated(rand(10), 20)
animate(itr, ylims=(0, 1), c=:red, fps=5)
Error evaluating It must be updated_plot8
LoadError: IOError: could not spawn `ffmpeg -v 0 -i 'C:\Users\hermesr\AppData\Local\Temp\jl_797E.tmp/%06d.png' -vf palettegen=stats_mode=diff -y 'C:\Users\hermesr\AppData\Local\Temp\jl_797E.tmp/palette.bmp'`: no such file or directory (ENOENT)
in expression starting at C:\Users\hermesr\Documents\Julia software\Julia Scripts\It must be updated_plot8:10
_jl_spawn(::String, ::Array{String,1}, ::Cmd, ::Tuple{RawFD,RawFD,RawFD}) at process.jl:367
(::getfield(Base, Symbol("##494#495")){Cmd})(::Tuple{RawFD,RawFD,RawFD}) at process.jl:509
setup_stdio(::getfield(Base, Symbol("##494#495")){Cmd}, ::Tuple{RawFD,RawFD,RawFD}) at process.jl:490
#_spawn#493(::Nothing, ::Function, ::Cmd, ::Tuple{RawFD,RawFD,RawFD}) at process.jl:508
_spawn at process.jl:504 [inlined]
#run#504(::Bool, ::Function, ::Cmd) at process.jl:662
run at process.jl:661 [inlined]
#buildanimation#228(::Int32, ::Int32, ::Bool, ::Bool, ::Function, ::String, ::String, ::Bool) at animation.jl:82
#buildanimation at none:0 [inlined]
#buildanimation at none:0 [inlined]
#gif#225 at animation.jl:63 [inlined]
#gif at none:0 [inlined]
#animate#223(::Base.Iterators.Pairs{Symbol,Int32,Tuple{Symbol,Symbol},NamedTuple{(:fps, :loop),Tuple{Int32,Int32}}}, ::Function, ::Plots.FrameIterator, ::String) at animation.jl:46
#animate at none:0 [inlined]
using Plots
using Base.Iterators
#itr = repeated(()->rand(10), 20)
#animate(itr, ylims=(0,1), c=:red, fps=5)
##2
#itr = zip(rand(10))
#animate(zip)
###3
#itr = repeated(rand(10), 20)
#animate(itr, ylims=(0, 1), c=:red, fps=5)
####4
#it must be the way the anonymous function in repeated() works:
#julia-1.0> collect(repeated(() -> rand(10), 20)
itr=collect(repeated(() -> rand(10), 20) )
animate(itr, ylims=(0, 1), c=:red, fps=5)
ERROR: LoadError: getfield(Main, Symbol("##13#14"))() is not a Function, or is not defined at any of the values [-5.0, -1.0, 0.0, 0.01]
Stacktrace:
[1] tryrange(::getfield(Main, Symbol("##13#14")), ::Array{Float64,1}) at C:\Users\hermesr\.julia\packages\Plots\rmogG\src\series.jl:412
[2] macro expansion at C:\Users\hermesr\.julia\packages\Plots\rmogG\src\series.jl:389 [inlined]
[3] apply_recipe(::Dict{Symbol,Any}, ::getfield(Main, Symbol("##13#14"))) at C:\Users\hermesr\.julia\packages\RecipesBase\Uz5AO\src\RecipesBase.jl:275
[4] _process_userrecipes(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{getfield(Main, Symbol("##13#14"))}) at C:\Users\hermesr\.julia\packages\Plots\rmogG\src\ppeline.jl:83
[5] macro expansion at .\logging.jl:305 [inlined]
[6] _plot!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{getfield(Main, Symbol("##13#14"))}) at C:\Users\hermesr\.julia\packages\Plots\rmogG\src\plot.jl:171
[7] #plot#132(::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol},NamedTuple{(:ylims, :c),Tuple{Tuple{Int32,Int32},Symbol}}}, ::Function, ::Function) at C:\Users\hermesr\julia\packages\Plots\rmogG\src\plot.jl:57
[8] (::getfield(RecipesBase, Symbol("#kw##plot")))(::NamedTuple{(:ylims, :c),Tuple{Tuple{Int32,Int32},Symbol}}, ::typeof(plot), ::Function) at .\none:0
[9] #animate#223(::Base.Iterators.Pairs{Symbol,Int32,Tuple{Symbol,Symbol},NamedTuple{(:fps, :loop),Tuple{Int32,Int32}}}, ::Function, ::Plots.FrameIterator, ::String) at C:\Uers\hermesr\.julia\packages\Plots\rmogG\src\animation.jl:42
[10] #animate at .\none:0 [inlined]
[11] #animate#224 at C:\Users\hermesr\.julia\packages\Plots\rmogG\src\animation.jl:51 [inlined]
[12] #animate at .\none:0 [inlined] (repeats 2 times)
[13] top-level scope at none:0
in expression starting at C:\Users\hermesr\Documents\Julia software\Julia Scripts\It must be updated_plot8:15
julia>