更改绘图轴

更改绘图轴

知道如何将 X 轴改为 0-100 吗?同时删除 10^-2 并将 Y 轴改为 0-0.025?谢谢。 在此处输入图片描述

\begin{figure}
\resizebox{\linewidth}{!}{

    \begin{tikzpicture}
    \begin{axis}
    \addplot [ybar interval, mark=no] plot coordinates
    {(0,0.0043973941368078175) (0.1,0.006677524429967427)  (0.2,0.016938110749185668)
         (0.3,0.02280130293159609)  (0.4,0.0250814332247557)  (0.5,0.016042345276872965) (0.6,0.006758957654723126)  (0.7,0.0038273615635179142)  (0.8,0.0028501628664495127)  (0.9,0.0018729641693811076)  (1,0.0018729641693811076)};
    \end{axis}
    \end{tikzpicture}
}
\caption{users’ average charge levels at start of charge \cite{hu2019modeling}}
\label{fig:1}
\end{figure}

答案1

请查看代码中的注释。

% used PGFPlots v1.16
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        % don't scale y ticks ...
        scaled y ticks=false,
        % ... and format them properly
        yticklabel style={
            /pgf/number format/.cd,
                fixed,
                fixed zerofill,
                precision=3,
        },
    ]
        \addplot [
            ybar interval,
        % changed `coordinates` to a `table` because then ...
        ] table [
            % ... it is easy to manipulate the values
            x expr=\thisrow{x}*100,
        ] {
            x   y
            0.0 0.0043973941368078175
            0.1 0.006677524429967427
            0.2 0.016938110749185668
            0.3 0.02280130293159609
            0.4 0.0250814332247557
            0.5 0.016042345276872965
            0.6 0.006758957654723126
            0.7 0.0038273615635179142
            0.8 0.0028501628664495127
            0.9 0.0018729641693811076
            1.0 0.0018729641693811076
        };
    \end{axis}
\end{tikzpicture}
\end{document}

该图显示了上述代码的结果

相关内容