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 would like to draw an arc between to lines in a pgfplots picture using axis cs. My first attempt is as follows:

    \documentclass[12pt,a4paper]{article}
    \usepackage{pgfplots}

    \pgfplotsset{compat=newest}

    \begin{document}

    \begin{center}
    \begin{tikzpicture}
        \begin{axis}[xmin=-8,xmax=8,xtick={-8,-6,...,8},
            ymin=-8,ymax=8,ytick={-8,-6,...,8},grid=major
            ,view={0}{90},x post scale={2},y post scale=2
            ]
        \addplot[black,thin,domain=0:8]{0};
        \addplot[black,thin,domain=0:8]{2.3962931*x};
        \draw [->] (axis cs:2,0) arc [radius=17mm,start angle=0,end angle=64.3];
    \end{axis}
    \end{tikzpicture}
    \end{center}

    \end{document}

However, the value of the radius and angle needed to be determined via trial and error. Hence, if I change the scaling (as used with x post scale and y post scale) then the arc does not display correctly.

Clearly, I have missed something and there should be a straight forward way to achieve my aims. I can change the arc to a circle (set radius=2 (with no units)) and I get what I expect and it scales.

Any insights would be much appreciated.

Peter Johnston.

share|improve this question
add comment

1 Answer

The easiest thing to do in this case is to set disabledatascaling, in which case canvas and axis units are the same (i.e. \draw (0,0) -- (1,1) has the same effect as \draw (axis cs:0,0) -- (axis cs:1,1)). That will only work if your units are within a "reasonable" range that doesn't cause over- or underflows. In your case, it'll work fine. Note that you should also set axis equal, otherwise your arc will be squashed a bit.

\documentclass[12pt,a4paper]{article}
    \usepackage{pgfplots}

    \pgfplotsset{compat=1.5.1}

    \begin{document}

    \begin{center}
    \begin{tikzpicture}
        \begin{axis}[xmin=-8,xmax=8,xtick={-8,-6,...,8},
            ymin=-8,ymax=8,ytick={-8,-6,...,8},grid=major
            ,view={0}{90},x post scale={2},y post scale=2, disabledatascaling, axis equal
            ]
        \addplot[black,thin,domain=0:8]{0};
        \addplot[black,thin,domain=0:8]{2.3962931*x};
        \draw [thick, ->] (axis cs:2,0) arc [radius=2,start angle=0,end angle=64.3];
    \end{axis}
    \end{tikzpicture}
    \end{center}

    \end{document}
share|improve this answer
1  
You could also use \pgfmathsetmacro{\EndAngle}{atan(2.3962931)} and use \EndAngle instead of 64.3 (which does not quite connect to the line). –  Peter Grill Jun 18 '12 at 4:54
    
Thanks Jake, that seemed to work just fine. –  Peter Johnston Jun 18 '12 at 5:51
    
@PeterJohnston you can accept Jake's answer; in case of doubt, please see How do you accept an answer?. –  Gonzalo Medina Jun 20 '12 at 2:11
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.