I want to draw an unit circle(cos+sin), using numpy and matplotlib. I wrote the following:
t = np.linspace(0,np.pi*2,100)
circ = np.concatenate((np.cos(t),np.sin(t)))
and I plotted, but failed.
ax.plot(t,circ,linewidth=1)
ValueError: x and y must have same first dimension
plot
does not do a parametric plot. You must give it the x
and y
values, not t
.
x
is cos(t)
and y
is sin(t)
, so give those arrays to plot
:
ax.plot(np.cos(t), np.sin(t), linewidth=1)