# Plotting nonlinear ODEs in Julia

**URL:** https://discourse.julialang.org/t/plotting-nonlinear-odes-in-julia/105918
**Category:** General Usage
**Tags:** plotting
**Created:** [November 7, 2023, 11:47pm UTC](https://discourse.julialang.org/t/plotting-nonlinear-odes-in-julia/105918 "2023-11-07T23:47:57Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![00krishna](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00krishna/32/8843_2.png) [@00krishna](https://discourse.julialang.org/u/00krishna)
#### Post date: [November 7, 2023, 11:47pm UTC](https://discourse.julialang.org/t/plotting-nonlinear-odes-in-julia/105918/1 "2023-11-07T23:47:57Z")

</div>

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.

![Selection_005](https://global.discourse-cdn.com/julialang/original/3X/1/c/1ccd92d1dcedfe0980538c46cbf9f63abe2d7748.png)

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.

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

 ![Selection_006](https://global.discourse-cdn.com/julialang/original/3X/b/f/bfec2a4ba06e6799218ad8faec9ab0f829ccfb65.png)

---

<div class="post-metadata">

### Author: ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)
#### Post date: [November 8, 2023, 10:24am UTC](https://discourse.julialang.org/t/plotting-nonlinear-odes-in-julia/105918/2 "2023-11-08T10:24:01Z")

</div>

One way would be to use annotations:

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

---

<div class="post-metadata">

### Author: ![00krishna](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00krishna/32/8843_2.png) [@00krishna](https://discourse.julialang.org/u/00krishna)
#### Post date: [November 8, 2023, 7:27pm UTC](https://discourse.julialang.org/t/plotting-nonlinear-odes-in-julia/105918/3 "2023-11-08T19:27:37Z")

</div>

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.
