3
$\begingroup$

wikipedia

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.

$\endgroup$
1
  • 1
    $\begingroup$ nparange -> np.arange $\endgroup$
    – P2000
    Sep 4, 2020 at 1:28

1 Answer 1

1
$\begingroup$

(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.

Organize your ax.plot() as follows:

  1. x = frequency index
  2. y = imag
  3. z = real
$\endgroup$
3
  • 1
    $\begingroup$ could you make a working example that i can execute? $\endgroup$
    – Khan
    Sep 4, 2020 at 13:19
  • 1
    $\begingroup$ how about you edit your code with the above suggestions, and if you're stuck maybe I can have a look at it. $\endgroup$
    – P2000
    Sep 4, 2020 at 16:11
  • $\begingroup$ i tried it and your comments do not help, I dont know how to proceed. For me my ax.plot is already organized as you mentioned... $\endgroup$
    – Khan
    Aug 2, 2021 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.