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.


x  ind2    ind3
0  0.22507 0.99741
1  0.22507 nan
2  0.22507 0.99741
3  0.22507 nan


\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};


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.

  • 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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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