I plotted a line using 10 coordinates from between 0 to 1 in 0.1 step size. Each Y-coordinate is an average value. I have the variance for each average value and want to plot a filled area around the function that depicts the variance. My code so far:
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{subfig}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{figure}[h!]
\begin{subfigure}[t]{0.82\textwidth}
\resizebox{1\textwidth}{!}{%
\begin{tikzpicture}
\begin{axis}[
xmin=0, xmax=1.1,
ymin=16.9, ymax=17.3,
xlabel={x}, ylabel={y}, axis lines=left,
xtick={0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1},
xticklabels={0, , , , , 0.5, , , , , 1},
ytick distance={0.1},
xticklabel style={rotate=-0, yshift=-0.4ex},
xlabel style={anchor=north},
xmajorgrids=true,
grid style=dashed,
legend pos=outer north east,
height=6cm,
]
\addplot coordinates {
(0, 17.2)
(0.1, 16.91)
(0.2, 17.04)
(0.3, 17.26)
(0.4, 17.11)
(0.5, 17.08)
(0.6, 17.11)
(0.7, 17.24)
(0.8, 17.23)
(0.9, 17.16)
(1, 17.22)
};
\end{axis}
\end{tikzpicture}
}
\caption{my cap}
\end{subfigure}%
\end{figure}
\end{document}
For example each Y-coordinate should have a variance of 0.1 to 0.3, visualized as filling around the function/line. I want to specify the variance, thus the size of the "tube" around the function for each of the 10 points individually. How to accomplish this? My variance values are:
(0, 0.03)
(0.1, 0.03)
(0.2, 0.06)
(0.3, 0.01)
(0.4, 0.02)
(0.5, 0.03)
(0.6, 0.05)
(0.7, 0.11)
(0.8, 0.04)
(0.9, 0.09)
(1, 0.05)
The variance should look something like the gray filled area in this example:


\documentclass{}and ends with\end{document}that we can compile please? It helps people help you if we can copy and paste immediately and trial solutions, please include whatever minimal amount of packages we need to compile it on our computers :) – JamesT Aug 30 '23 at 20:39