我想垂直对齐几个随机信号波形,如下图所示这个帖子。
但是,给出的答案似乎不适用于我的情况,因为我只能绘制两条曲线,如以下 MWE 所示:
\documentclass[xcolor={dvipsnames,svgnames,table}, 8pt]{beamer}
\usepackage{tikz}
\begin{document}
\frame{
\frametitle{Test}
\begin{columns}
\begin{column}{.3\textwidth}
\centering
\begin{tikzpicture}[
declare function={
excitation(\t,\w) = sin(\t*\w);
noise = rnd - 0.5;
source(\t) = excitation(\t,20) + noise;
filter(\t) = 1 - abs(sin(mod(\t, 50)));
speech(\t) = 1 + source(\t)*filter(\t);
}
]
\draw[orange, thick, x=0.0085cm, y=.5cm] (0,1) -- plot [domain=0:360, samples=144, smooth] (\x,{speech(\x)});
\node[align=center] { \\[1cm]$\vdots$\\[1cm]};
\draw[orange, thick, x=0.0085cm, y=-0.5cm] (0,1) -- plot [domain=0:360, samples=144, smooth] (\x,{speech(\x)});
\end{tikzpicture}
\end{column}
\end{columns}
}
\end{document}
我怎样才能垂直对齐,比如说 3 个信号波形(第二个和第三个之间有垂直点)?
答案1
或者,稍微简化和更短的代码:
\documentclass[xcolor={dvipsnames,svgnames,table}]{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
\frametitle{Speech signal}
\frametitle{Test}
\begin{columns}
\begin{column}{.3\textwidth}
\centering
\begin{tikzpicture}[
x=0.0085cm, y=0.5cm,
declare function={
excitation(\t,\w) = sin(\t*\w);
noise = rnd - 0.5;
source(\t) = excitation(\t,20) + noise;
filter(\t) = 1 - abs(sin(mod(\t, 50)));
speech(\t) = 1 + source(\t)*filter(\t);
},
orange, thick, smooth, % <--- moved here
domain=0:360, samples=144, % <--- moved here
]
\draw plot (\x,{6+speech(\x)}); % <---
\draw plot (\x,{3+speech(\x)}); % <---
\draw plot (\x,{0+speech(\x)}); % <---
%
\draw[black, densely dotted, very thick] (0,2.2) -- (0,2.8)
(0,5.2) -- (0,5.8);
\end{tikzpicture}
\end{column}
\begin{column}{.7\textwidth}
content of the second column
\end{column}
\end{columns}
\end{frame}
\end{document}
答案2
您可以使用该yshift
选项来垂直移动图表。
\documentclass[xcolor={dvipsnames,svgnames,table}, 8pt]{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
\frametitle{Test}
\begin{columns}
\begin{column}{.3\textwidth}
\centering
\begin{tikzpicture}[
declare function={
excitation(\t,\w) = sin(\t*\w);
noise = rnd - 0.5;
source(\t) = excitation(\t,20) + noise;
filter(\t) = 1 - abs(sin(mod(\t, 50)));
speech(\t) = 1 + source(\t)*filter(\t);
}
]
\draw[orange, thick, x=0.0085cm, y=.5cm] (0,1) -- plot [domain=0:360, samples=144, smooth] (\x,{speech(\x)});
\draw[densely dotted, thick] (0,1.2) -- (0,1.7);
\draw[orange, thick, x=0.0085cm, y=.5cm,yshift=1.3cm] (0,1) -- plot [domain=0:360, samples=144, smooth] (\x,{speech(\x)});
\draw[densely dotted, thick] (0,2.5) -- (0,3.0);
\draw[orange, thick, x=0.0085cm, y=.5cm,yshift=2.6cm] (0,1) -- plot [domain=0:360, samples=144, smooth] (\x,{speech(\x)});
\end{tikzpicture}
\end{column}
\end{columns}
\end{frame}
\end{document}