# Plot the Theodorus Spiral with Plots

**URL:** <https://discourse.julialang.org/t/plot-the-theodorus-spiral-with-plots/61720>\
**Category:** General Usage\
**Tags:** package, plot\
**Created:** [May 24, 2021, 1:23pm UTC](https://discourse.julialang.org/t/plot-the-theodorus-spiral-with-plots/61720 "2021-05-24T13:23:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HerAdri](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heradri/32/5816_2.png) [@HerAdri](https://discourse.julialang.org/u/HerAdri)\
**Post date:** [May 24, 2021, 1:23pm UTC](https://discourse.julialang.org/t/plot-the-theodorus-spiral-with-plots/61720/1 "2021-05-24T13:23:58Z")

</div>

Tried to reproduce the following code from the [link](https://theredforgepublishinghouse.com/learn-maths-with-the-theodorus-spiral/) in Julia

But I can’t configure the graphics part correctly.  
I show you where I have been:

```julia
#https://theredforgepublishinghouse.com/learn-maths-with-the-theodorus-spiral/
#clear all
using Plots
using Printf
total_angle=0;
winding=0;
plt=plot();
@printf("x hyp X Y winding \n")
for x in 1:16
    hyp=sqrt(x+1);
    angle=atan(1/sqrt(x));
    total_angle=total_angle+angle;
    X=hyp*cos(total_angle);
    Y=hyp*sin(total_angle);
    degtotal_angle=total_angle*180/pi;
    winding=degtotal_angle/360;
    hypb=sqrt(x);
    Xb=hypb*cos(total_angle-angle);
    Yb=hypb*sin(total_angle-angle);
    plot!(plt,Vector[[0, 1],[0 ,0]],color=:blue,lw=3,leg=false) #first spoke
    plot!(plt,Vector[[0, X],[0, Y]],color=:blue,lw=3,leg=false) #spokes
    plot!(plt,Vector[[Xb,X],[Yb, Y]],color=:blue,lw=3,leg=false) #boundary
    @printf("%3d %4.4f %4.4f %4.4f %4.4f \n", x, hyp, X, Y, winding); 
end
    plt

```

---

<div class="post-metadata">

**Author:** ![AndiMD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andimd/32/6531_2.png) [@AndiMD](https://discourse.julialang.org/u/AndiMD)\
**Post date:** [May 24, 2021, 1:56pm UTC](https://discourse.julialang.org/t/plot-the-theodorus-spiral-with-plots/61720/2 "2021-05-24T13:56:49Z")

</div>

Hi, its just how Plots interprets the data vector.  
Change  
`plot!(plt,Vector[[0, 1],[0 ,0]],color=:blue,lw=3,leg=false)`  
into  
`plot!(plt,[0, 1],[0 ,0],color=:blue,lw=3,leg=false)`

---

<div class="post-metadata">

**Author:** ![HerAdri](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heradri/32/5816_2.png) [@HerAdri](https://discourse.julialang.org/u/HerAdri)\
**Post date:** [May 24, 2021, 2:30pm UTC](https://discourse.julialang.org/t/plot-the-theodorus-spiral-with-plots/61720/3 "2021-05-24T14:30:40Z")

</div>

Thanks, with that change and adding annotations = ((X + Xb) / 3, (Y + Yb) / 3, text (“$ x”,: left)). the graph is obtained:

```julia
plot!(plt,[0, 1],[0 ,0],color=:blue,lw=3,leg=false) #first spoke
plot!(plt,[0, X],[0, Y],color=:blue,lw=3,leg=false) #spokes
plot!(plt,[Xb,X],[Yb, Y],color=:blue,lw=3,leg=false,annotations=((X+Xb)/3, (Y+Yb)/3, text("$x", :left))) #boundary

```

![Theodorus Spiral](https://global.discourse-cdn.com/julialang/original/3X/6/9/692f166987c39a154daac43ed4ca7ed599c65b83.jpeg)
