我想126.0
在我的nodes near coords
后面添加一个尾随零。
目前它看起来是这样的:
当我添加该行时,nodes near coords style={/pgf/number format/.cd,fixed zerofill,precision=1},
它会添加尾随零,但也会重新处理我的,0.2
因此它看起来像$2 \cdot 10^(-1)$
:
我如何显示126.0
和0.2
同时
先感谢您!
完整代码:
\documentclass[
conference,
]{IEEEtran}
\usepackage{siunitx}
\DeclareSIUnit\twh{\tera\watt\hour}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar,
enlargelimits=0.15,
ylabel={Stromerzeugung in \SI{}{\twh}},
symbolic x coords={
Windenergie,
Biomasse,
Photovoltaik,
Wasserkraft,
Geothermie
},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
% nodes near coords style={/pgf/number format/.cd,fixed zerofill,precision=1},
x tick label style={rotate=45,anchor=east},
]
\addplot[black,fill=black!50!white] coordinates {
(Windenergie,126.0) (Biomasse,50.4) (Photovoltaik,47.5) (Wasserkraft,20.2) (Geothermie,0.2)
};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
添加fixed
到nodes near coords style
:
nodes near coords style={/pgf/number format/.cd,fixed,fixed zerofill,precision=1}
\documentclass[
conference,
]{IEEEtran}
\usepackage{siunitx}
\DeclareSIUnit\twh{\tera\watt\hour}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar,
enlargelimits=0.15,
ylabel={Stromerzeugung in \SI{}{\twh}},
symbolic x coords={
Windenergie,
Biomasse,
Photovoltaik,
Wasserkraft,
Geothermie
},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
nodes near coords style={/pgf/number format/.cd,fixed,fixed zerofill,precision=1},% <- changed
x tick label style={rotate=45,anchor=east},
]
\addplot[black,fill=black!50!white] coordinates {
(Windenergie,126.0) (Biomasse,50.4) (Photovoltaik,47.5) (Wasserkraft,20.2) (Geothermie,0.2)
};
\end{axis}
\end{tikzpicture}
\end{document}