I am using the accepted answer to the question “Is there an easy way of using line thickness as an error indicator in a plot?” to draw error bands around my regular line plots.
However, I find myself wanting to plot two lines with slightly different x ranges, which makes pgfplots complain:
Package pgfplots Error: Sorry, pgfplots expects stacked plots to have exactly the same number of coordinates. Unfortunately, I encountered at plot with DIFFERENT NUMBERS OF COORDINATES. Please verify that 1. no point has been dropped by coordinate filters (for example log(0) or so) and 2. all plots have the same number of coordinates..
Is there a way to start the stacked plot over "from scratch" within the same axis/scale so that this error does not occur?
For example, in the example below, commenting out either the code for plotting table A or B will make it work, but as it is, it will give the error above:
\documentclass[a4paper]{article}
\usepackage{fullpage}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\pgfplotstableread{
0 10 12
1 10 11
2 8 9
3 15 16
4 13 15
5 20 21
}\tableA
\pgfplotstableread{
2 20 23
3 19 21
4 20 22
}\tableB
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}
% Table A
\addplot [draw=none, stack plots=y, forget plot] table [x={0}, y expr={\thisrowno{1}}] {\tableA};
\addplot [draw=none, stack plots=y, forget plot, fill=gray!25] table [x={0}, y expr={\thisrowno{2}-\thisrowno{1}}] {\tableA} \closedcycle;
% Table B
\addplot [draw=none, stack plots=y, forget plot] table [x={0}, y expr={\thisrowno{1}}] {\tableB};
\addplot [draw=none, stack plots=y, forget plot, fill=gray!25] table [x={0}, y expr={\thisrowno{2}-\thisrowno{1}}] {\tableB} \closedcycle;
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}


yvalues be when they are not specified? 0? If so, then make it so (0 0 0, 1 0 0, 5 0 0). pgfplots cannot guess your missing values. – knittl Sep 09 '12 at 11:44/pgfplots/y filter/.code) – knittl Sep 09 '12 at 11:55