# Drawing Line Plot with uncertainty

Does anyone have an idea how to generate a graph with the 'uncertainty' area like in the picture shown: i have no idea where to start!

Thanks for any inspiration!

Cheers! Martin

• Yes, I do think that several people have an idea. Not sure, though, if any of them wants to try to recreate your figure from a screen shot. Please post an example showing what you've tried, i.e. a plot without the halos. – marmot Oct 9 '18 at 14:39
• And you may look at this answer. – marmot Oct 9 '18 at 14:58

To give you a start. All I did was to marginally modify Jake's error bar command. I was not in the mood to read off the coordinates from your screen shot so I made some up.

\documentclass{article}
\usepackage{pgfplots, pgfplotstable}
\pgfplotsset{compat=1.16}
\usepackage{filecontents}
\begin{filecontents*}{data.dat}
x y error
2 0.95 0.2
4.5 0.8 0.12
8 0.85 0.085
11 0.86 0.09
14 0.87 0.07
\end{filecontents*}
\begin{document}

\newcommand{\errorband}[5][]{ % x column, y column, error column, optional argument for setting style of the area plot
% Lower bound (invisible plot)
\addplot [draw=none, stack plots=y, forget plot] table [
x={#3},
y expr=\thisrow{#4}-2*\thisrow{#5}
] {\datatable};

% Stack twice the error, draw as area plot
\addplot [draw=none, fill=gray!40, stack plots=y, area legend, #1] table [
x={#3},
y expr=4*\thisrow{#5}
] {\datatable} \closedcycle;

% Reset stack using invisible plot
\addplot [forget plot, stack plots=y,draw=none] table [x={#3}, y expr=-(\thisrow{#4}+2*\thisrow{#5})] {\datatable};
}

\begin{tikzpicture}[font=\sffamily]
\begin{axis}[grid=major,xlabel=whatever,ylabel=dunno]

\errorband[red, opacity=0.2]{data.dat}{x}{y}{error}