6

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.

4
  • 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 Commented Jun 27, 2012 at 11:59
  • @Jake Before that the starred version of the filecontents environment should be used. But still I couldn't make it work. Commented Jun 27, 2012 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). Commented Jun 27, 2012 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. Commented Jun 27, 2012 at 12:15

1 Answer 1

4

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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.