4

How can I add ^\circ to all xticklabels in a polaraxis plot? The following attempt adds a lot of filling zeros:

\begin{tikzpicture}
    \def\y{50}
    \begin{polaraxis}[
            xtick={0,30,...,330},
            xticklabel={${\tick}^\circ$},
            xticklabel style={anchor=\tick+180},
            ytick={-30,-20,...,20},
            grid=both,
            ymin=-\y, 
            ymax=30,
            xmin=0, 
            xmax=360,
            y coord trafo/.code=\pgfmathparse{#1+\y}, % done in order to get negative values on y axis
            y coord inv trafo/.code=\pgfmathparse{#1-\y}, % normalize previous step
        ]
    \end{polaraxis}
\end{tikzpicture} 

Also, is it possible to have the yticklabels on the "yaxis" instead?

enter image description here

2

In this case it is sufficient to convert the ticks to integers.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{polar}
\begin{document}
\begin{tikzpicture}
    \def\y{50}
    \begin{polaraxis}[
            xtick={90,120,...,450},
            xticklabel={\pgfmathtruncatemacro{\mytick}{\tick}${\mytick}^\circ$},
            xticklabel style={anchor=\tick+180},
            ytick={-30,-20,...,20},
            grid=both,
            ymin=-\y, 
            ymax=30,
            xmin=90, 
            xmax=450,
            y coord trafo/.code=\pgfmathparse{#1+\y}, % done in order to get negative values on y axis
            y coord inv trafo/.code=\pgfmathparse{#1-\y}, % normalize previous step
        ]
    \end{polaraxis}
\end{tikzpicture} 
\end{document}

enter image description here

  • 1
    (+1) I was too slow but did it just with \pgfmathprintnumber – koleygr Nov 14 '18 at 16:05
  • Thanks! Is it easy to solve the second question as well? "Also, is it possible to have the yticklabels on the "yaxis" instead?" – user2978680 Nov 14 '18 at 16:36
  • @user2978680 Yes, of course. – user121799 Nov 14 '18 at 16:42

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.