Drawing random signal shape in tikz?

Is it possible in tikz - in a simple way to draw a signal...

I am interested in drawing something like this

The shape of the signal does not matter... I just have to be able to draw the arrows and the text in between.

Regarding the meta post:

My intention with this post was never to have someone give me the full solution. I was only interested in possible ways a random signal could be created, which was given by the sine solution ... I seen now that the title/question might have been misleading. Sorry for the troubles it might have caused you.

• Maybe the Hobby package could help. ftp.tu-chemnitz.de/pub/tex/graphics/pgf/contrib/hobby/hobby.pdf Apr 23, 2017 at 12:39
• I would as much as possible like to avoid shaping the wave..
– dfh
Apr 23, 2017 at 12:45
• I would just use a sum of sin waves with different frequency and phase. It will look random :). Apr 23, 2017 at 13:26
• @Dr.ManuelKuehner Thats a great Idea!..
– dfh
Apr 23, 2017 at 13:45
• Apr 25, 2017 at 9:21

Pure TikZ solution:

\documentclass[tikz,
border=3mm,
]{standalone}
\usetikzlibrary{arrows.meta,
quotes
}
\begin{document}
\begin{tikzpicture}[x=16mm,
every edge/.style = {draw, Straight Barb-Straight Barb},
every edge quotes/.style = {fill=white,font=\footnotesize}
]
\draw[very thick,red, smooth,domain=9:101] plot (\x/10,rand);

\foreach \x in {1, 3, 4, 5, 7, 6, 8, 9, 10}
\draw[dashed]  (\x,-1.1) -- ++ (0,2.2);

\draw   (3.0,-1.3) edge ["Frame step"] ++ (2,0)
(5.0,-1.3) edge ["Overlap"] ++ (1,0)
(1.0,-1.6) edge ["Frame 1"] ++ (3,0)
(5.0,-1.6) edge ["Frame 3"] ++ (3,0)
(3.0,-1.9) edge ["Frame 2"] ++ (3,0)
(7.0,-1.9) edge ["Frame 4"] ++ (3,0);
\end{tikzpicture}
\end{document}

• Ah... Nice ended up with a similar solution.
– dfh
Apr 23, 2017 at 13:59

I'm bored, so here's a suggestion with some help from pgfplots.

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}

\begin{document}
\begin{tikzpicture}[
doublearrow/.style={
<->,
>=latex,
every node/.style={fill=white,font=\scriptsize}}]
\begin{axis}[
axis lines=none,
clip=false,
width=12cm,
height=3cm
]
\pgfmathsetseed{1} % to get same output every time
\pgfplotsinvokeforeach{1,3,3.5,5,7,7.5,9}{% draw vertical dotted line at these x-positions
\draw [densely dotted] (#1,0) -- (#1,1.5);
}

% draw arrows with text
\draw [doublearrow] (1,-0.2) -- node{Frame 1} (3.5,-0.2);
\draw [doublearrow] (3,-0.4) -- node{Frame 2} (5,-0.4);
\end{axis}
\end{tikzpicture}
\end{document}


And because I was working on this while other answers were posted, with just TikZ. I've made some macros that hold frame width, step etc., so that you can easily modify if needed. Change one macro, and all the arrows move as well. (I'm assuming the frame width and step are constant here.)

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
doublearrow/.style={
<->,
>=latex,
every node/.style={fill=white,font=\scriptsize}}]

\pgfmathsetseed{42}
\draw plot[smooth,domain=0:12,samples=25] (\x,rnd);

\pgfmathsetmacro\FrameStart{1}
\pgfmathsetmacro\FrameW{3}
\pgfmathsetmacro\FrameOverlap{0.5}
\pgfmathsetmacro\FrameStep{\FrameW-\FrameOverlap}

\foreach[
evaluate=\i as \y using {ifthenelse(mod(\i,2)==0,-0.4,-0.8)},
evaluate=\i as \X using \i*\FrameStep+\FrameStart,
count=\j
] \i in {0,...,3} {
\draw [densely dotted] (\X,0) -- (\X,1.5);
\draw [densely dotted] (\X+\FrameW,0) -- (\X+\FrameW,1.5);
\draw [doublearrow] (\X,\y) -- node{Frame \j} (\X+\FrameW,\y);
}
\draw [doublearrow] (\FrameStart+\FrameStep,1.3) -- node{Frame step} +(\FrameStep,0);
\draw [doublearrow] (\FrameStart+3*\FrameStep,1) -- node[above=2pt,font=\tiny]{Overlap} +(\FrameOverlap,0);

\end{tikzpicture}
\end{document}

• Thanks for taking the time to make a solution.. I think i will go with @ Dr.ManuelKuehner suggestion, and add some sines together...
– dfh
Apr 23, 2017 at 13:56
• @dfh I added one more suggestion, as I was working on it anyway. It's a bit more "automated" than Zarko's. Apr 23, 2017 at 14:14
• If the person who downvoted this two hours ago sees this, I would appreciate a comment explaining the reason for the downvote. Apr 25, 2017 at 10:25
• @ShreevatsaR That may well be, and I fully understand that people react to the discrepancy/hypocrisy shown in that Meta-question, but that still doesn't justify downvoting both answers to this question within four seconds of each other (I'm guessing here that the same person downvoted Zarko's answer, but I may of course be wrong about that). If my answer is wrong/misleading/terrible, by all means downvote it, but don't downvote an answer because the question is bad -- if that was the reason. Apr 25, 2017 at 15:11
• @ShreevatsaR There was no one else to address it to ... Sorry though, shouldn't have directed that whole rant at you. Apr 25, 2017 at 15:17

I made this solution based on @Dr.ManuelKuehner 's suggestion:

\begin{figure}[H]
\centering
\begin{tikzpicture}
% Frame length: 3
% Overlap length:0.6
% Frame start sections: 0 - 1.4 - 2.8 - 4.2
% Frame end sections: 2 - 3.4 - 4.8 - 4.2

\draw[->]   (-1,0) -- ++ (12,0) node[right] {Time}; %X-axis line
\draw[thick, blue] plot[domain=0:11.7*pi, samples=60]  (\x/pi,{sin(0.9*\x r) + sin(0.42*\x r)}); %sine wave

\draw[densely dashed]   (0,-1.5) -- + (0,3.0)      (3,-1.5) -- + (0,3.6);% frame 1
\draw[<->]      (0,-1.3) -- node[below] {Frame 1} + (3,0);

\draw[densely dashed]   (2.4,-1.1) -- + (0,3.3)      (5.4,-1.1) -- + (0,4.1);
\draw[<->]      (2.4,2.1) -- node[above] {Overlap} + (0.6,0);
\draw[<->]      (2.4,-2.1) -- node[below] {Frame 2} + (3,0);

\draw[densely dashed]   (4.8,-1.5) -- + (0,4.4)      (7.8,-1.5) -- + (0,3.6);
\draw[<->]      (4.8,2.9) -- node[above] {Overlap} + (0.6,0);
\draw[<->]      (4.8,-1.3) -- node[below] {Frame 3} + (3,0);

\draw[densely dashed]   (7.2,-1.1) -- + (0,3.3)      (10.2,-1.1) -- + (0,3.3);
\draw[<->]      (7.2,2.1) -- node[above] {Overlap} + (0.6,0);
\draw[<->]      (7.2,-2.1) -- node[below] {Frame 4} + (3,0);

\end{tikzpicture}
\end{figure}