TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there an easy way of drawing a noisy waveform in TikZ? I know you can draw a simple sinusoid by repeatedly using cos and sin for every half-period, but doing that for a noisy waveform seems like a massive undertaking and a very roundabout way of doing it.

I'm looking for something like this: Noisy waveform

It doesn't have to be that long, a fifth of the length is fine. I'm diagramming a noise reduction system and need to show a noisy waveform as the input to the diagram (whereas the rest of the diagram is simple rectangular boxes and text...).

Any ideas?

share|improve this question
Thanks for that. I just discovered TikZ today and it's surprisingly powerful! – jodles Nov 10 '13 at 21:30
up vote 25 down vote accepted

You can use \draw plot for plotting functions. For the noise, you can use the rand function.

In general, plotting is more comfortable using the PGFPlots package, which builds on PGF/TikZ:

    \begin{tikzpicture}[samples=200, domain=0:5*360]
            width=10cm, height=4cm,
            enlarge x limits=false,
            axis lines*=middle,
            hide y axis
        \addplot [no markers, smooth] {sin(x)+rand*2};
share|improve this answer
why sin(x) and not only rand? – Pygmalion Dec 13 '15 at 21:13
I just think it's a prettier function than pure noise. No technical reason though (but jodles did ask for a "noisy waveform" and not "pure noise", so I guess it's closer to what they were looking for) – Jake Dec 13 '15 at 21:19
OK. I need white noise and I am using something like +rand-rand+rand-rand to make it as random as possible. – Pygmalion Dec 13 '15 at 21:21
@Pygmalion: I don't think that actually increases the randomness. It does change the distribution of your values, though, which might be undesirable: see stackoverflow.com/a/3956538/1456857 – Jake Dec 13 '15 at 21:38

This is a derived example from the »PGF/TikZ« user guide.


    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[help lines] (0,1) -- (3,1);
    \draw[blue, thick, x=0.0085cm, y=1cm] (0,1) -- plot [domain=0:360, samples=144, smooth] (\x,{speech(\x)});

Customization is left to you.

enter image description here

share|improve this answer

With PSTricks.

\pstVerb{realtime srand}

    \psplot[linecolor=red]{-3.8}{3.8}{x 5 mul RadtoDeg sin Rand 4 mul 1 sub mul 1.8 mul}

enter image description here


Note that Rand no longer produces a random real number between 0 and 0.5 inclusive. Its definition had been tacitly changed. Now it produces a random real number between 0 and 1 inclusive. It is not documented, nor announced, but it is still fun!

The code given above has not been updated yet so it will produce different output. I have no time to update it right now. Sorry for this inconvenience.

share|improve this answer
A plot continuously moving from right to left would be even cooler. – AlexG Nov 11 '13 at 7:51
@AlexG: Yes. I will see it later. – kiss my armpit Nov 11 '13 at 8:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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