How to plot the DFT transformation of a vector with tikz/pgfplots?

My question seems to be simple but still I could not find any answer for that. Assume that we have a vector and its DFT which I computed it in R.

> x <- c(3,9,4,2,5,6,2,6)
> x
[1] 3 9 4 2 5 6 2 6
> fft(x)
[1] 37.000000+0.000000i  2.949747-1.292893i  2.000000-7.000000i -6.949747+2.707107i -9.000000+0.000000i -6.949747-2.707107i  2.000000+7.000000i  2.949747+1.292893i


I stored the DFT coefficients in input.txt. Now, I want to plot these complex numbers stored in input.txt with tikz/pgfplots. I read this link, but it is just based on the exponential form of the complex numbers. So, I have no idea if it is possible to draw the plot without converting the complex numbers to the exponential form.

I don't know if this is the type of plot that you are looking for, but anyway the file MWE.Rnw below should serve to get the idea of the alternative way to obtain your desired plot with knitr.

MWE.Rnw

\documentclass{article}
\begin{document}
<<myplot,dev='tikz', echo=F,warning=F, fig.height=3, fig.width=3>>=
x <- c(3,9,4,2,5,6,2,6)
plot(sort(x),sort(fft(x)),type='l',col="red",
xlab="$x$",ylab="\\texttt{fft($x$)}")
@
\end{document}

• I am looking for a plot like this: i.stack.imgur.com/ZLhB7.png – ThisIsMe Jun 27 '20 at 19:50
• @ThisIsMe, please edit your question and make it more clear. For example add above comment to it. – Zarko Jul 21 at 10:22