Struggling_Student
Struggling_Student

Reputation: 464

Julia plot function stopped working properly

Fore some reason Julia refuses to plot my code

using Plots

n = 100
ϕ = range(0,stop=2*π,length=n)
x =  cos.(ϕ)';
y =  sin.(ϕ)';
plot(x,y)

enter image description here

The last time I used the same code Julia plotted: enter image description here

and I already tried

enter image description here

I didn't change anything since the last time when Julia's plot function worked properly. so I am not sure what I am doing wrong.

Upvotes: 0

Views: 156

Answers (2)

Benoit Pasquier
Benoit Pasquier

Reputation: 3005

FWIW, you can also plot a parametric function t ↦ [x(t), y(t)] with plot(x, y, t), e.g.,

plot(cos, sin, range(0,2π,length=100))

Upvotes: 1

cbk
cbk

Reputation: 4370

Try instead just

using Plots

n = 100
ϕ = range(0,stop=2*π,length=n)
x =  cos.(ϕ);
y =  sin.(ϕ);
plot(x,y)

The transposes are turning the results into row vectors, and Plots is trying to plot each column as a separate series.

Upvotes: 2

Related Questions