如何将 ^\circ 添加到极轴图中的所有 xticklabels?以下尝试添加了很多填充零:
\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}
另外,是否可以将 yticklabels 放在“yaxis”上?
答案1
在这种情况下,将刻度转换为整数就足够了。
\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}