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.

I create a plot with pgfplots with the following code:

\documentclass{standalone}
\usepackage{tikz} 
\usepackage{pgfplots}
\pgfplotsset{compat=1.6}

\begin{filecontents}{ExampleData.txt}
xValue1 yValue1 Deltay1
-0.405  0       0
-0.355  0       0
-0.305  1       1
-0.245  2       1.41
-0.195  117     10.82
-0.155  111     10.54
-0.105  132     11.49
-0.055  142     11.92
-0.005  122     11.05
0.045   109     10.44
0.095   135     11.62
0.145   131     11.45
0.195   110     10.49
0.245   42      6.48
0.295   0       0
0.345   0       0
0.395   0       0
0.445   0       0
0.495   0       0
\end{filecontents}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
%clip mode=individual,
xmin=-0.5,xmax=0.5,ymin=0,ymax=150, 
enlargelimits=false,
axis on top=true,
xlabel=$x$, ylabel=$y$]
\addplot[dashed,
color=blue,
thick,
%only marks,
mark=*,
/pgfplots/error bars/.cd,
    x dir=none,
    y dir=both,
    y explicit,
    error bar style={color=blue,solid}] 
table [
x=xValue1,
y=yValue1,
y error=Deltay1] {ExampleData.txt};
\draw[thick, <->] (axis cs:-0.195,117) -- (axis cs:0.195,117);
\end{axis}
\end{tikzpicture}
\end{document}

The output

Plot with marked problems

is almost what I want to have, but there are some things I am not able to improve by myself:

If I use a dashed line instead of a solid one, the markers are not a round disk anymore. How can I avoid this?

I want to have the arrow in the foreground. I thought I can use clip mode=individual for that. But then sometimes my error bars are being plotted outside of my axes. How can I have my arrow in the foreground without creating such an effect?

I would be very happy about some help!

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

Or you can play with the layers to get different effects such as clipping the markers or leaving on the axis lines etc.

\documentclass{standalone}
\usepackage{tikz} 
\usepackage{pgfplots}
\pgfplotsset{compat=1.6}

\begin{filecontents}{ExampleData.txt}
xValue1 yValue1 Deltay1
-0.405  0       0
-0.355  0       0
-0.305  1       1
-0.245  2       1.41
-0.195  117     10.82
-0.155  111     10.54
-0.105  132     11.49
-0.055  142     11.92
-0.005  122     11.05
0.045   109     10.44
0.095   135     11.62
0.145   131     11.45
0.195   110     10.49
0.245   42      6.48
0.295   0       0
0.345   0       0
0.395   0       0
0.445   0       0
0.495   0       0
\end{filecontents}

\begin{document}

\begin{tikzpicture}
\begin{axis}[set layers,
xmin=-0.5,xmax=0.5,ymin=0,ymax=150, 
enlargelimits=false,
axis on top=true,
xlabel=$x$, ylabel=$y$]
\addplot[dashed,
color=blue,
thick,
mark=*,
mark options={thin,solid}, %<--- Change
mark layer=like plot,      %<--- Change
/pgfplots/error bars/.cd,
    x dir=none,
    y dir=both,
    y explicit,
    error bar style={color=blue,solid}] 
table [
x=xValue1,
y=yValue1,
y error=Deltay1] {ExampleData.txt};
\draw[thick, <->,on layer=axis foreground] (axis cs:-0.195,117) -- (axis cs:0.195,117);
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
Sorry for the bad image cropping. –  percusse Nov 26 '12 at 12:00
    
Ah, much better! –  Jake Nov 26 '12 at 12:05
    
Thank you so much for this answer! You have solved all my problems in a very easy way! Thanks again! –  partial81 Nov 26 '12 at 20:51
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.