[Tex/LaTex] Axis ticks in radians in polar pgfplots

pgfplotspolartikz-pgf

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.

Best Answer

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}

enter image description here

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.

Related Question