2

This only happened after I updated to latest pgfplots version v 1.11 and used to be compiled with a fine looking result.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\usepackage{amsmath}

%\usetikzlibrary{}

\begin{document}
    \begin{tikzpicture}      

        \begin{axis}[%
            scale mode = scale uniformly,
            grid=none,
            xmin=-1.2,
            xmax= 1.2,
            ymin=-.55,
            ymax= .55,
            xtick={-1,-0.5,...,1},
            ytick={-1,-0.5,...,1},
            minor y tick num=3,
            minor x tick num=1,
            width= .75\textwidth,
            height=.33\textwidth,
            scale only axis,
            xlabel={x},
            ylabel={y}
        ]

            \pgfmathsetmacro{\radius}{.5};
            \pgfmathsetmacro{\gamma}{35};
            \pgfmathsetmacro{\beta}{20};

            \draw [black!80] (0,0) arc[start angle=90, delta angle=\gamma-90, radius=\radius];

            \draw [ultra thick] (0,-0.5) arc[start angle=-90, end angle=180, radius=\radius];

        \end{axis}          
    \end{tikzpicture}%
\end{document}

I get the following result, which I can't understand. Where is the distortion coming from? I should see a nice 3/4 circle, shouldn't I?

2 Answers 2

4

This is a bug in pgfplots 1.11: it comes with a new feature which allows to write (1,1) instead of (axis cs:1,1). Unfortunately, that feature was applied in a wrong way when it comes to arcs. In other words: yes, this is a bug in pgfplots 1.11 .

It has already been addressed and will become part of pgfplots 1.12 (planned for January 2015). Your example works fine (without modifications) in the prerelease version of pgfplots 1.12 .


A workaround appears to be:

  1. use compat=1.10
  2. use disabledatascaling
  3. use (axis cs:0,0) instead of (0,0) .

    \documentclass{standalone}
    \usepackage{tikz}
    \usepackage{pgfplots}
    \pgfplotsset{compat=1.10}
    \usepackage{amsmath}
    
    %\usetikzlibrary{}
    
    \begin{document}
    \begin{tikzpicture}      
    
        \begin{axis}[%
            disabledatascaling,
            scale mode = scale uniformly,
            grid=none,
            xmin=-1.2,
            xmax= 1.2,
            ymin=-.55,
            ymax= .55,
            xtick={-1,-0.5,...,1},
            ytick={-1,-0.5,...,1},
            minor y tick num=3,
            minor x tick num=1,
            width= .75\textwidth,
            height=.33\textwidth,
            scale only axis,
            xlabel={x},
            ylabel={y}
        ]
    
            \pgfmathsetmacro{\radius}{.5};
            \pgfmathsetmacro{\gamma}{35};
            \pgfmathsetmacro{\beta}{20};
    
            \draw [black!80] (axis cs:0,0) arc[start angle=90, delta angle=\gamma-90, radius=\radius];
    
            \draw [ultra thick] (axis cs:0,-0.5) arc[start angle=-90, end angle=180, radius=\radius];
    
        \end{axis}          
    \end{tikzpicture}%
    \end{document}
    

enter image description here

1

I guess there is some problem about units when pgfplots is processing the coordinates of, say, control points. (On the other hand, the end points of your arc are at the right place.) In this case, I found that specifying a unit make the arc more like an arc. For instance:

\draw[black!80](0,0)arc[start angle=90,delta angle=\gamma-90,radius=\radius pt];

But this then ignores axis cs the (default) coordinate system since you assign an explicit length. After some works you can extract the scaling factor and multiply \radius by it. Now everything looks fine.

\documentclass[tikz]{standalone}
\usepackage{pgfplots}\pgfplotsset{compat=1.11}
\begin{document}
    \begin{tikzpicture}
    \begin{axis}[scale mode=scale uniformly,xmin=-1.2,xmax= 1.2,ymin=-.55,ymax= .55]
        \pgfplotsextra{
            \pgfplotstransformdirectionx{1}
            \pgfmathsetlengthmacro{\ex}{\pgfmathresult*\pgfplotsunitxlength}
            \pgfmathsetmacro{\radius}{.5*\ex};\pgfmathsetmacro{\gamma}{35};}
        \draw[black!80](0,0)arc[start angle=90,delta angle=\gamma-90,radius=\radius pt];
        \draw[ultra thick](0,-0.5)arc[start angle=-90,end angle=180,radius=\radius pt];
    \end{axis}
    \end{tikzpicture}
\end{document}
2
  • This solves the issue, but I happen to think that this can't be the real solution. It's more of a workaround, don't you think? I hope Christian looks stumbels over this and has something to point out. Thanks for the help though! I appreciate it.
    – goeck
    Jan 7, 2015 at 8:47
  • @goeck It is a workaround. Consider to submit a bug report if it really bothers you. I posted this answer but not just calling a bug because specifying an explicit radius makes more sense. Since the x-vector and the y-vector may be of different length, one should not expect tikz to use either one as radius by default. (Although ellipse[x radius=1,y radius=2] makes sense, and compiles.)
    – Symbol 1
    Jan 7, 2015 at 9:17

You must log in to answer this question.

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