我想在坐标附近的节点中设置百分比。例如,0.33 变成 33% 而不是 0.33%。此时,它会在节点后设置百分号。有人能帮我吗?
{
\begin{figure}[h!]
\centering
\resizebox {0.45\textwidth} {!} {
\begin{tikzpicture}
\begin{axis}[
ybar,
enlargelimits=1,
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
ylabel={Gearing},
yticklabel ={\pgfmathparse{\tick*100}\pgfmathprintnumber{\pgfmathresult}\,\%},
symbolic x coords={Vorig jaar,Huidig jaar},
xtick=data,
nodes near coords={\pgfmathprintnumber\pgfplotspointmeta\,\%},
nodes near coords align={vertical},
bar width = 1.5cm,
ymajorgrids =true,
]
\addplot[fill ,color=ZandersGreen]
coordinates {(Vorig jaar,-0.33) (Huidig jaar,1.5)};
\end{axis}
\end{tikzpicture}
}
\caption{Gearing vergeleken met de benchmark (links) en over tijd (rechts)\VAR{n5excepPlot}}
\end{figure}
}
答案1
你可以做(小心)在按键中做一些计算pgfplots
...
如果您将您的更改nodes near coordinates
为:
nodes near coords={\pgfkeys{/pgf/fpu}\pgfmathparse{\pgfplotspointmeta*100}\pgfmathprintnumber{\pgfmathresult}\,\%},
您有这个(经过一番努力编译您的示例后) - 下次请按照构建最小工作示例 (MWE) 的说明: