Consider the function and a call to this function. Notice the placement of @df on the first line of myPlot().
There is a spae before the @df macro. Everything runs fine. However, if I remove this space, then when compiling myPlot in Atom, I get the error that df_jump is not defined. I understand that the macro executes before the call to the function, so it is expanding on something that is not defined. But if this is true, why does adding a space before the @ symbol solve the problem? I do not understand. Thanks.
function run_plot(tot_pop) prop_infected = 0.001 I0 = floor(Int, tot_pop * prop_infected) S0 = tot_pop - I0 u0 = [S0,I0,0]; prob = DiscreteProblem(u0,tspan) prob_jump = JumpProblem(prob,Direct(),sir_model) sol_jump = solve(prob_jump,SSAStepper()); out_jump = sol_jump(t); df_jump = DataFrame(out_jump') df_jump[!,:t] = out_jump.t; myPlot(df_jump) end function myPlot(df_jump) @df df_jump plot(:t, [:x1 :x2 :x3], label=["S" "I" "R"], xlabel="Time", ylabel="Number") end time run_plot(10000)