pgfplots 中的尾随 Zeron

pgfplots 中的尾随 Zeron

我想126.0在我的nodes near coords后面添加一个尾随零。

目前它看起来是这样的:

在此处输入图片描述

当我添加该行时,nodes near coords style={/pgf/number format/.cd,fixed zerofill,precision=1},它会添加尾随零,但也会重新处理我的,0.2因此它看起来像$2 \cdot 10^(-1)$

在此处输入图片描述

我如何显示126.00.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

添加fixednodes 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}

相关内容