# how to plot fft with imaginary and real part in 3d or calculate the degree of rotation

I would like to make a plot like 1 and see the real and imaginary part in a 3d space. I dont want to make exactly the same plot. for me it is okay if i see the peak for both signals shifted. it is also ok for me if i can only calculate the rotation without plotting.

I tried it with a 3d plot python matplotlib

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3d

//create example Signal, sinus and cosinus-> they are shifted in time so i would like to see the rotation in complex plane

time = np.arange(1000)/1000)
signalSinus= np.sin(100*2.0*np.pi*time)
signalCosinus = np.sin(100*2.0*np.pi*time+np.pi)

fftSinus = np.fft.fft(signalSinus)
ftCosinus = np.fft.fft(signalCosinus)

fig=plt.figure()
ax=fig.gca(projection='3d')
ax.plot(np.fft.rfft(len(fftSinus),d=1/1000),np.imag(fftSinus),np.real(ffSinus)) // three axis plot but how to?
plt.show() //


i dont get right results it looks pretty strange to me :D if i plot both signals they look the same.

• nparange -> np.arange Sep 4, 2020 at 1:28

(1) nparange -> np.arange, and

(2) np.fft.rfft(len(fftSinus),d=1/1000)

You want the frequency values. You can start with just np.arange(1000) for normalized frequency, or frequency indices, and worry about actual values later.