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!

enter image description here

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.
    – user121799
    Oct 9 '18 at 14:39
  • And you may look at this answer.
    – user121799
    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.

\usepackage{pgfplots, pgfplotstable}
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

\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 [
        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 [
        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};


\errorband[red, opacity=0.2]{data.dat}{x}{y}{error}
\addplot [red,mark=*,thick] table [
    x index=0,
    y index=1] {data.dat};



enter image description here

  • I will check that out - that is more than I expected! Thanks a lot @marmot!
    – Styp
    Oct 9 '18 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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