3

I am trying to create a plot of a quantity in the time and frequency domain as shown below. The plot shown is a modified plot already discussed here.

However, I need to plot data from a file using (probably, but not necessarily) \addplot or \addplot3 instead of plotting an analytical function by means of \draw as used in the code below. Moreover, I also need to add ticks and numbers (scales) to the axes. I expect that an axis environment should be used in this case.

I therefore tried to add the axis environment, but with no success. Do you have any idea how to accomplish it?

Thanks for any advice!

enter image description here

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[x={(0.7cm,1cm)},z={(0cm,1cm)},y={(1cm,0cm)}]

    \draw[->] (0,-pi,0) --++ (6,0,0) node[above right] {Frequency};
    \draw[->] (0,-pi,0) --++ (0,6.5,0) node[right] {Time};
    \draw[->] (0,-pi,0) --++ (0,0,1.5) node[above] {Magnitude};

    \foreach \y in {1,2,...,5}{

    \draw[blue] plot[domain = -pi:+pi, samples = 300] 
        (\y,\x,{0.2*cos(10*\y/2*(\x) r)});
        \draw[blue] (\y,-pi-0.15,0) node [left]{$f_{\y}$};       
    }

    \draw[red, thick] plot[domain = -pi:+pi, samples = 2000] 
    (0,\x,{0.02*sin(50*(\x) r)/(\x))});

\end{tikzpicture}
\end{document}

1 Answers1

2

enter image description here The following code could be more than a simple starting point.

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\begin{document}
\begin{tikzpicture}
\begin{axis}[view={20}{80}, domain=0:10*pi, samples=1000, samples y=0, thick,
    xmin=0, xmax=10*pi, xtick=\empty,      xticklabel=\empty,                                   xlabel=Time,      axis line style={->}, axis x line=center, xlabel style={anchor=north},
    ymin=1, ymax=7,     ytick={1,2,...,6}, yticklabels={{}, $f_1$, $f_2$, $f_3$, $f_4$, $f_5$}, ylabel=Frequency, axis line style={->}, axis y line=center, ylabel style={anchor=west}, yticklabel style={anchor=south east, blue},
    zmin=-1, zmax=2,    ztick=\empty,      zticklabel=\empty,                                   zlabel=Magnitude, axis line style={->}, axis z line=center, zlabel style={anchor=east}
]
\addplot3[red] ({x}, {1}, {2*sin(deg(10*(x-5*pi)))/(10*(x-5*pi))});
\addplot3[blue] ({x}, {2}, {-cos(deg(x))});
\addplot3[blue] ({x}, {3}, {cos(deg(2*x))});
\addplot3[blue] ({x}, {4}, {-cos(deg(3*x))});
\addplot3[blue] ({x}, {5}, {cos(deg(4*x))});
\addplot3[blue] ({x}, {6}, {-cos(deg(5*x))});
\end{axis}
\end{tikzpicture}
\end{document}

For what concerns the view, I sincerely never did anything else than set view={<azimuth>}{<elevation>}; you could check $4.10.1 of the revision 1.13 of the pgfplots manual.

Enlico
  • 2,592