# Adding jitter to a straight line

I have found a post about: How to add a jitter to a scatter plot with pgfplots. I’d like to add jitter to a straight green line to recreate this graph..

Would this be the best way do you think? Also are the arrows decorations?

    \documentclass{standalone}
\usepackage{pgfplots}
\usepackage{amsmath}

\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin=-4,xmax=+0, ymin=-0.5,ymax=4.5, axis lines=left]

samples=100]
{2}
node [midway, above right] {\small $\bar{U}$ Time-average velocity};

\end{axis}
\end{tikzpicture}
\end{document}


#### Solutions Collecting From Web of "Adding jitter to a straight line"

This approach is really similar to vrleboss’ suggestion, but in order to fit the arrow for the fluctuating velocity, we’ll need to simulate autocorrelated noise (or try lots of realisations of the uncorrelated noise).

Here I’ve used a product of two cosine functions as the base function, and then added random noise on top:

\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{amsmath}

\begin{document}
\begin{tikzpicture}
\pgfmathsetseed{1}
\begin{axis}[xmin=-4,xmax=+0, ymin=-0.5,ymax=4.5, axis lines=left,
clip=false]

samples=2]
{2}
node [right] {\small $\bar{U}$ Time-average velocity};
samples=100]
{2+0.8*cos(x*300)*cos(x*50)+rand/5}
node [red, right] {\small $U$ Instantaneous velocity}
coordinate [pos=0.25] (point);
\draw [ultra thick, blue, latex-latex] (point) -- (point|-{axis cs:0,2}) node [pos=0, anchor=-160] {$u'$ Fluctuating velocity};
\end{axis}
\end{tikzpicture}
\end{document}


I would use the rand function. The decoration produces non-causal curves.

\begin{tikzpicture}
\begin{axis}[xmin=-4,xmax=+0, ymin=-0.5,ymax=4.5, axis lines=left]

node [midway, above right] {\small $\bar{U}$ Time-average velocity};