pgfplots can deal with missing values in table inputs by either skipping or jumping over any values which are given as nan
in the input table file, as discussed here. I want to do a similar thing with error bar plots. In particular, several entries of the table column where errors are given are set to nan
, as in the code example below. I'd like to have a result where error bars are only plotted on points where non-nan
values are available.
\documentclass[11pt]{article}
\usepackage{pgfplots}
\begin{filecontents}{tabletest.data}
x ind2 ind3
0 0.22507 0.99741
1 0.22507 nan
2 0.22507 0.99741
3 0.22507 nan
\end{filecontents}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xlabel=x,ylabel=y,no markers]
\addplot plot[error bars/.cd,y dir=plus,y explicit,error mark=diamond*]
table[x=x,y=ind2,y error=ind3] {tabletest.data};
\end{axis}
\end{tikzpicture}
\end{document}
Unfortunately, compilation fails with the errors Missing number, treated as zero.
and Illegal unit of measure (pt inserted).
When replacing nan
by numeric values, the file compiles, but of course has error bars on all points.
Is there another reasonably way to get error bars only on part of the plotted points from table data, or is this a missing feature in pgfplots?
This question has an answer suggesting the use of gnuplot, but I'd like to do it without gnuplot.
Best Answer
This is a missing feature in pgfplots 1.5.1 . It will be present in the next stable after 1.5.1 (probably 1.6).