# Sketching Phase Portrait in Julia

**URL:** <https://discourse.julialang.org/t/sketching-phase-portrait-in-julia/88441>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [October 8, 2022, 2:19pm UTC](https://discourse.julialang.org/t/sketching-phase-portrait-in-julia/88441 "2022-10-08T14:19:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [October 8, 2022, 2:19pm UTC](https://discourse.julialang.org/t/sketching-phase-portrait-in-julia/88441/1 "2022-10-08T14:19:53Z")

</div>

Dear All,

I watch this on youtube tutorial and wonder can Julia plot phase portrait from a matrix?

[![](https://global.discourse-cdn.com/julialang/original/3X/a/c/ac88580930a478fedae8ce31284d2a44bb6580bb.jpeg "sketching phase portraits") ](https://www.youtube.com/watch?v=dpbRUQ-5YWc)

![Capture d’écran_2022-10-08_21-17-07](https://global.discourse-cdn.com/julialang/original/3X/f/e/fe652d75170d136e68af1d0f3f87fe62296909b5.png)

I also try the LinearAlgebra and why does the eigenvectors different from the tutorial?

this is my code:

```julia
using LinearAlgebra
A = [4 0;
     2 -1]

eigvals(A)

eigvecs(A)

```

thanks all

---

<div class="post-metadata">

**Author:** ![skleinbo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skleinbo/32/36080_2.png) [@skleinbo](https://discourse.julialang.org/u/skleinbo)\
**Post date:** [October 8, 2022, 2:46pm UTC](https://discourse.julialang.org/t/sketching-phase-portrait-in-julia/88441/2 "2022-10-08T14:46:02Z")

</div>

> [@Freya\_the\_Goddess](#):
>
> I also try the LinearAlgebra and why does the eigenvectors different from the tutorial?

Because they are normalized.

> can Julia plot phase portrait from a matrix?

Maybe this discussion: [Plotting a phase portrait of a differential equation - #6 by airpmb](https://discourse.julialang.org/t/plotting-a-phase-portrait-of-a-differential-equation/29208/6) can provide some inspiration.

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [October 8, 2022, 3:26pm UTC](https://discourse.julialang.org/t/sketching-phase-portrait-in-julia/88441/3 "2022-10-08T15:26:42Z")

</div>

take a look at:

> **[ode solution - Beautiful Makie](https://beautiful.makie.org/dev/examples/generated/2d/streamplot/ode_solution/)**
>
> Makie Examples

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [October 9, 2022, 1:45pm UTC](https://discourse.julialang.org/t/sketching-phase-portrait-in-julia/88441/4 "2022-10-09T13:45:54Z")

</div>

Your code is not working with my CairoMakie and Makie

```julia
      Status `~/LasthrimProjection/JupyterLab/DifferentialEquations/Project.toml`
  [13f3f980] CairoMakie v0.8.13
  [5c1252a2] GeometryBasics v0.4.4
  [ee78f7c6] Makie v0.17.13
  [eacbb407] Meshes v0.25.1
  [91a5bcdd] Plots v1.33.0

```

 ![Capture d’écran_2022-10-09_20-44-14](https://global.discourse-cdn.com/julialang/original/3X/e/a/ea549d21a39e13d23c67bf0306d690e5c4d8c9f8.png)

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [October 9, 2022, 2:17pm UTC](https://discourse.julialang.org/t/sketching-phase-portrait-in-julia/88441/5 "2022-10-09T14:17:57Z")

</div>

weird that you don’t get the point type right. Try

```julia
using CairoMakie

odeSol(x, y) = CairoMakie.Point2f(-x, 2y) # x'(t) = -x, y'(t) = 2y
fig = Figure(resolution = (600, 400))
ax = Axis(fig[1, 1], xlabel = "x", ylabel = "y", backgroundcolor = :black)
streamplot!(ax, odeSol, -2 .. 4, -2 .. 2, colormap = Reverse(:plasma),
    gridsize = (32, 32), arrow_size = 10)
fig

```

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [October 11, 2022, 4:10am UTC](https://discourse.julialang.org/t/sketching-phase-portrait-in-julia/88441/6 "2022-10-11T04:10:44Z")

</div>

It is still not working with the same errors.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [October 11, 2022, 10:51am UTC](https://discourse.julialang.org/t/sketching-phase-portrait-in-julia/88441/7 "2022-10-11T10:51:30Z")

</div>

Is something else exporting `Point2f` too? Try `Makie.Point2f`
