5

I would like to create a plot with error bars in which y is restricted to a given domain. Unfortunately, restrict y to domain does not seem to work with error bars.

\documentclass{article}
\usepackage{pgfplots}
\usepackage[latin1]{inputenc}
\usepackage[ngerman]{babel}
\pgfplotsset{compat=newest}

\pagestyle{empty}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
scaled ticks=false,
width = 0.9\linewidth,
height = 0.5562\linewidth,
xlabel={\footnotesize Testinstanzen},
ylabel={\footnotesize relative Abweichung},
xtick=\empty,
yticklabel={\footnotesize ~\pgfmathparse{\tick*100}\pgfmathprintnumber{\pgfmathresult}\%}
]

\addplot+[only marks,
color = blue,
mark = *,
mark options={fill=blue},
mark size = 1.5,
error bars/.cd,
error bar style={color=blue},
y dir = both,
y explicit,
x dir = none]
table[x index={0},y index={1}, y error plus index ={2}, y error minus index ={3}]plots/data/data.dat};  
\end{axis}
\end{tikzpicture}
\end{document}

This code creates the following plot:

plot where y is not restricted

I would like to restrict y from 0% to 1%, so that the error bars are easier to recongnize. The long error bar at the fourth dot should end at the very top of the plot to indicate that the corresponding value is even higher than 1%.

Thank you very much for your help!

Example data file "data.dat":

0   0.0274  0.0775  0.0274
1   0.0275  0.0386  0.0271
2   0.0274  0.0407  0.0274
3   0.0260  0.0570  0.0247
4   0.0297  0.0560  0.0248
5   0.0465  0.1102  0.0405
6   0.0371  0.0808  0.0371
7   0.0381  0.0471  0.0337
8   0.0267  0.0387  0.0234
9   0.0247  0.0274  0.0247
3
  • Please make this into a complete compilable document and provide a sample data file to use. Apr 29, 2014 at 14:00
  • 1
    You can set ymax=0.15 to set the visible range. Does that solve the problem?
    – Jake
    Apr 30, 2014 at 18:49
  • Yes, this solved the problem. Thanks Jake, thanks Christian!
    – JavAlex
    May 5, 2014 at 11:31

1 Answer 1

4

The restriction is currently not applied to error bars. This is either a bug or a feature request in pgfplots.

The only workaround so far is the one suggested by @Jake: to set ymax=0.15. It should work reasonably unless the error bar value is orders of magnitude above the standard scale of your data points.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .