# Plotting functions of the DE solutions

**URL:** <https://discourse.julialang.org/t/plotting-functions-of-the-de-solutions/89837>\
**Category:** General Usage\
**Tags:** plotting, functions, differentialequation\
**Created:** [November 6, 2022, 5:30am UTC](https://discourse.julialang.org/t/plotting-functions-of-the-de-solutions/89837 "2022-11-06T05:30:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sh\_166](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sh_166/32/43965_2.png) [@Sh\_166](https://discourse.julialang.org/u/Sh_166)\
**Post date:** [November 6, 2022, 5:30am UTC](https://discourse.julialang.org/t/plotting-functions-of-the-de-solutions/89837/1 "2022-11-06T05:30:55Z")

</div>

Hi, so, I was trying to plot a function that takes the solution of a DE as it’s arguments. In particular, [these](https://discourse.julialang.org/t/symbolics-jl-modelingtoolkit-jl-differentialequations-jl-and-the-lagrangian-approach/89629/5) 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](https://diffeq.sciml.ai/stable/basics/plot/) example and have the following code:

```julia
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.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [November 10, 2022, 2:08pm UTC](https://discourse.julialang.org/t/plotting-functions-of-the-de-solutions/89837/2 "2022-11-10T14:08:07Z")

</div>

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