如何绘制以 -60 为基值而不是 0(默认值)的以下条形图?
\documentclass[convert={density=400,outext=.png}]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}[baseline]
\centering
\begin{axis}[ybar,bar width=1,line width=2,
ylabel=Output Power(dBm),
xlabel=Frequency(GHz),label style={font=\bfseries\LARGE},
legend style={legend pos= south east},
tick label style={font=\bfseries\Large},
grid=major,anchor=north]
\addplot coordinates
{(100,-24)(200,5.5)(300,-55)(400,-9.5)};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
我不太清楚你所说的基数是什么意思,但有一种可能性是将相对值转移到-60
\documentclass[convert={density=400,outext=.png}]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}[baseline]
\centering
\begin{axis}[
ybar,
bar width=1,
line width=2,
ylabel=Output Power(dBm),
xlabel=Frequency(GHz),
label style={font=\bfseries\LARGE},
legend style={legend pos= south east},
tick label style={font=\bfseries\Large},
grid=major,
anchor=north,
y coord trafo/.code={\pgfmathparse{#1+60}}, % Addition
y coord inv trafo/.code={\pgfmathparse{#1-60}} % Addition
]
\addplot coordinates{(100,-24)(200,5.5)(300,-55)(400,-9.5)};
\end{axis}
\end{tikzpicture}
\end{document}