Plotting functions of the DE solutions

Hi, so, I was trying to plot a function that takes the solution of a DE as it’s arguments. In particular, these are the equations I solved, and I wanted to plot something like the normal modes (linear combinations of the \theta and \phi). I followed the documentation example and have the following code:

v(t,x,y) = (t, N₂*(M/m₁ - Ω₂^2)*x - N₂*μ*y)  #v (generic function with 1 method)
plot(sol, idxs=(v,0,5,3))

(I have defined N_2, N_1, M, \mu properly; they are constant floats)
As can be seen, v is defined properly without problems, but I run into the following error:

KeyError: key :args not found

Stacktrace:
[1] getindex(h::Dict{Symbol, Any}, key::Symbol)
@ Base .\dict.jl:498
[2] RuntimeGeneratedFunctions.RuntimeGeneratedFunction(cache_tag::Type, context_tag::Type, ex::Expr; opaque_closures::Bool)
@ RuntimeGeneratedFunctions C:\Users\shiha.julia\packages\RuntimeGeneratedFunctions\6v5Gn\src\RuntimeGeneratedFunctions.jl:55
[3] _build_and_inject_function(mod::Module, ex::Expr)
@ Symbolics C:\Users\shiha.julia\packages\Symbolics\FGTCH\src\build_function.jl:182
[4] _build_function(::Symbolics.JuliaTarget, ::Num; conv::Function, expression::Type, expression_module::Module, checkbounds::Bool, states::SymbolicUtils.Code.LazyState, linenumbers::Bool, wrap_code::Nothing, cse::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Symbolics C:\Users\shiha.julia\packages\Symbolics\FGTCH\src\build_function.jl:126
[5] #build_function#350
@ C:\Users\shiha.julia\packages\Symbolics\FGTCH\src\build_function.jl:87 [inlined]
[6] macro expansion
@ C:\Users\shiha.julia\packages\Symbolics\FGTCH\src\plot_recipes.jl:8 [inlined]
[7] apply_recipe(plotattributes::AbstractDict{Symbol, Any}, #unused#::Type{Num}, v::Num)
@ Symbolics C:\Users\shiha.julia\packages\RecipesBase\6AijY\src\RecipesBase.jl:299
[8] _apply_type_recipe(plotattributes::Any, v::AbstractArray, letter::Any)
@ RecipesPipeline C:\Users\shiha.julia\packages\RecipesPipeline\o2vnV\src\type_recipe.jl:40
[9] macro expansion
@ C:\Users\shiha.julia\packages\RecipesPipeline\o2vnV\src\user_recipe.jl:138 [inlined]
[10] apply_recipe(plotattributes::AbstractDict{Symbol, Any}, x::Any, y::Any)
@ RecipesPipeline C:\Users\shiha.julia\packages\RecipesBase\6AijY\src\RecipesBase.jl:299
[11] _process_userrecipes!(plt::Any, plotattributes::Any, args::Any)
@ RecipesPipeline C:\Users\shiha.julia\packages\RecipesPipeline\o2vnV\src\user_recipe.jl:38
[12] recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)
@ RecipesPipeline C:\Users\shiha.julia\packages\RecipesPipeline\o2vnV\src\RecipesPipeline.jl:72
[13] _plot!(plt::Plots.Plot, plotattributes::Any, args::Any)
@ Plots C:\Users\shiha.julia\packages\Plots\AAjgN\src\plot.jl:232
[14] plot(args::Any; kw::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})
@ Plots C:\Users\shiha.julia\packages\Plots\AAjgN\src\plot.jl:107
[15] top-level scope
@ In[35]:1
[16] eval
@ .\boot.jl:368 [inlined]
[17] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base .\loading.jl:1428

Any help would be appreciated!!

Edit: I have figured out where the problem is; I defined the values of m_1, m_2 and the other constants through the initial condition vector for the DE (u_0 in the link). Therefore, whatever constants I defined here were not actual numerical values but symbolic ones. Is there any workaround for this? For now, I am just defining the constants again and plotting and it works.

2 Likes

I don’t understand the issue. Can you share a full example?