
我想以 dB 標度繪製極座標圖,在本例中我有正值和負值。通常在相反方向繪製負半徑,但藉助變換座標我得到了我想要的結果。
但現在存在一個問題,即負刻度和正刻度不完全對齊。我試過一個提示但這只能修正一點偏移。這可能是因為該解決方案是針對旋轉蜱問題給出的。
如何使半徑軸刻度正確對齊?
\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\begin{document}
\begin{tikzpicture}
\begin{polaraxis}[%
xtick={0,30,...,180},
ymin=-25,
ymax=10,
xmax=180,
y coord trafo/.code=\pgfmathparse{#1+25},
y coord inv trafo/.code=\pgfmathparse{#1-25},
xticklabel=$\pgfmathprintnumber{\tick}^\circ$,
yticklabel style={yshift=-0.5cm},
],
\addplot[%
]
coordinates{%
(0,-15)
(30,-5)
(90,0)
(120,5)
};
\end{polaraxis}
\end{tikzpicture}
\end{document}
答案1
正如已經提到的在問題下面的評論中, 刻度標籤是完美對齊。查看程式碼中的註釋以了解更多詳細資訊。
\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\begin{document}
\begin{tikzpicture}
\begin{polaraxis}[
ymin=-25,
ymax=10,
xmax=180,
% when you have at PGFPlots v1.13 you can use the `xtick distance' feature
% xtick={0,30,...,180},
xtick distance=30,
y coord trafo/.code=\pgfmathparse{#1+25},
y coord inv trafo/.code=\pgfmathparse{#1-25},
xticklabel=$\pgfmathprintnumber{\tick}^\circ$,
yticklabel style={
% draw a frame around the tick labels to see, that they are
% indeed centered
draw=red,
% (and use there is a better way to position the tick labels
% on the other side of the axis ...)
% yshift=-0.5cm,
anchor=near yticklabel opposite,
},
],
\addplot coordinates {
(0,-15) (30,-5) (90,0) (120,5)
};
\end{polaraxis}
\end{tikzpicture}
\end{document}