1

I want to create a polar plot only of the first quadrant of the circle (angles 0 to 90 degrees), but I can't get the ticks and labels right. Take this sample:

\documentclass{standalone}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.polar}
\pgfplotsset{width=10cm,compat=1.10}
\begin{document}
\begin{tikzpicture}
\begin{polaraxis}[
  domain=0:90,
  ymin=0, ymax=1.5,
  xmin=0, xmax=90,
  xlabel={angle},
  ylabel={radius},
  ytick pos=left,
]
\addplot {1};
\end{polaraxis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
  domain=0:90,
  ymin=0, ymax=1.5,
  xmin=0, xmax=90,
  xlabel={angle},
  ylabel={radius},
]
\addplot {1};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

Things I'd like and can't find a consistent way to get:

  1. Radius tick labels (horizontal axis) below the plot

  2. Label "radius" below the horizontal axis too.

  3. Remove the outer circle line, but still get tick marks and labels.

Also, the size does not match the requested "width", as it does with the accompanying Cartesian plot, I guess that's because the size is computed for the full circle. Is this intentional?

Would any of this be solved with a more recent pgfplots version?

3

I think the polar library is a "quick and dirty" implementation and seems not to be used very often, because there seem to be a couple of bugs in it, as you already have found out yourself. So it seems one has to place and draw all your needed stuff without the "intelligence" of PGFPlots.

If you want, you can add the bugs to the bug tacker. Best, each bug with a MWE.

\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
    \usetikzlibrary{pgfplots.polar}
    \pgfplotsset{width=10cm,compat=1.10}
\begin{document}
    \begin{tikzpicture}
        \begin{polaraxis}[
            domain=0:90,
            ymin=0, ymax=1.5,
            xmin=0, xmax=90,
            xlabel={angle},
            ylabel={radius},
            ytick pos=left,
            % move `yticklabels' below the axis line
%            yticklabel pos=lower,   % <-- doesn't seem to work in `polaraxis'
            % move them down by hand
            yticklabel style={
                anchor=north,
                yshift=-2pt,
            },
            % move ``radius'' label below the axis
            ylabel style={
                at={(axis cs:0,0.75)},
                anchor=near ticklabel opposite,
                yshift=-2ex,
            },
            % move ``angle'' label to 45° again
            xlabel style={
                at={(axis cs:45,1.7)},
                sloped={at position=45},
                anchor=near ticklabel,
                near ticklabel at=45,
            },
            % don't draw the axis lines
            axis line style={draw=none},
            % in case you want to draw the yaxis lines only
            % (but the line will then be drawn above marks ...)
            after end axis/.code={
                \draw (axis cs:0,1.5) -- (axis cs:0,0) -- (axis cs:90,1.5);
                % test the width of the plot
                \draw [red] (axis cs:-1,1.5) -- +(-5cm,0);
            },
%            % to scale only the axis (and not also the labels, etc.)
%            scale only axis=true,
        ]
            \addplot {1};
        \end{polaraxis}
    \end{tikzpicture}
\end{document}

code showing the result of above code

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.