# Axis ticks in radians in polar pgfplots

I am using the polar library with pgfplots to plot a graph like this:

\begin{tikzpicture}
\begin{polaraxis}
\addplot[mark = none, domain = 0.4:12, samples = 600, data cs = polarrad]{sin(x)};
\end{polaraxis}
\end{tikzpicture}


As described in the manual, this uses radians for the function, but the axis labels are still plotted in degrees. Instead of having the 0, 30, …, 330 tick labels, I would like 0π, π/6, … 11π/6 labels. I am convinced the solution must be quite simple, but I have not been able to find it yet.

-
Would xticklabel={$\pgfmathparse{\tick/180}\pgfmathprintnumber[frac,frac denom=6,frac whole=false]{\pgfmathresult}\pi$} option be sufficient for your needs? –  percusse Mar 3 '13 at 13:23
@percusse setting xticklabel has no effect when I try it? (redefining \pgfplots@show@ticklabel@@polar has some effect but I guess that isn't the official interface? –  David Carlisle Mar 3 '13 at 13:49
This is a solution that I could live with, thank you very much! (@DavidCarlisle it works for me.) Of course it would be nicer to have simplified fractions, but if this is the simplest solution, then I guess there is no built-in way to label axes using radians. –  Ruud v A Mar 3 '13 at 13:50
@DavidCarlisle You have to include \usepgfplotslibrary{polar}, let me cook up a MWE. –  percusse Mar 3 '13 at 13:51
@percusse yes I got that far and can run the MWE and get a plot. I guess I should just leave pgf questions to egreg... –  David Carlisle Mar 3 '13 at 13:58

I've simplified the fractions a little more

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\usepgfplotslibrary{polar}
\begin{document}

\begin{tikzpicture}
\begin{polaraxis}[
xticklabel={
\pgfmathparse{\tick/180}
\pgfmathifisint{\pgfmathresult}{$\pgfmathprintnumber[int detect]{\pgfmathresult}\pi$}%
{$\pgfmathprintnumber[frac,frac denom=6,frac whole=false]{\pgfmathresult}\pi$}
}
]
\addplot[mark = none, domain = 0.4:12, samples = 600, data cs = polarrad]{sin(x)};
\end{polaraxis}
\end{tikzpicture}

\end{document}


You can introduce yet another \ifnum inside the integer check to remove 1 from 1pi but seems like an overkill to me. It's pretty readable in my humble opinion.

-
oh flip I nearly answered this an hour ago and could have had lots of lovely tikz points but I added xticklabel to the wrong place (\addplot) +1 to you +0 to me:( –  David Carlisle Mar 3 '13 at 14:11
@DavidCarlisle Go ahaed and post it please I'm not super happy with the way it is anyways. :) –  percusse Mar 3 '13 at 14:12