# Plotting nonlinear ODEs in Julia

Hey folks. I am writing some instructional materials in a set of Pluto notebooks. The topic is nonlinear ODEs, so there are some plots from the Strogatz textbook that I want to emulate. I was wondering if anyone can tell me the easiest way to replicate these plots in either Plots.jl, or in Makie.jl.

Writing the plot of the function is easy enough. The tricky point is adding the arrow on the axes, as well as the half-open half-closed circles at the semi-stable fixed points. I know Plots.jl better than I know Makie, but I have not figured out a good way to do this in Plots.jl.

Any help would be appreciated.

Just as some starter code, I could plot the function on the right of the image above. Like I said, it is the arrays and equilibrium points that are throwing me off.

x = LinRange(-2.0, 2.0, 100)
f(x) = x^2
p = Plots.plot(x, f.(x), label="function", xlabel=L"x", ylabel=L"\dot{x}", ylims=(-4, 4))
Plots.scatter!(p, [0], [0], label="equilibria")


Here is the corresponding plot.

One way would be to use annotations:

x = LinRange(-2.0, 2.0, 100)
f(x) = x^2
p = Plots.plot(x, f.(x), label="function", xlabel=L"x", ylabel=L"\dot{x}", ylims=(-4, 4))
Plots.annotate!(p, 0, 0, "◐") # thats \cirfl
Plots.annotate!(p, -1, 0, "▶") # thats \blacktriangleright
Plots.annotate!(p, 1, 0, "▶", framestyle=:origin)
3 Likes

Oh yes, this is excellent. Thanks for showing me how to add these additional marks to the plot. This is exactly what I was looking for.