Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
Ah, it does indeed seem like this is a missing feature. It works if you provide the data as a coordinates list, so PGFplots definitely has the capability to omit error bars for some values, it just doesn't parse the table data correctly in this case. You might want to open a feature request at the Sourceforge site –  Jake Jun 27 '12 at 11:59
    
@Jake Before that the starred version of the filecontents environment should be used. But still I couldn't make it work. –  percusse Jun 27 '12 at 12:03
    
@percusse: Why should the starred version be used here? The info lines added by the unstarred filecontents environment don't do any harm (lines starting with # or % are ignored). –  Jake Jun 27 '12 at 12:07
    
@Jake You are right it doesn't do harm. I've changed two things at a time before the test which mislead me. But still there is no need to add info lines anyway. –  percusse Jun 27 '12 at 12:15
add comment

1 Answer

up vote 3 down vote accepted

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).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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