TiKZ 绘图轴上的年份是错误的

TiKZ 绘图轴上的年份是错误的

我正在构建这个情节: 在此处输入图片描述

我成功完成了,但如你所见,X 轴上的年份显示不正确。它显示的不是 2017 年,而是 2,017 年。请帮帮我!

\begin{tikzpicture}
\begin{axis}[xlabel={ 1 января 2017-2021 },ylabel={Рыночная каппитализация в млрд. долларов}, legend pos = north west, table/col sep = semicolon,
    height = 0.5\paperheight, 
    width = 0.65\paperwidth,
    xmin = 2017,
    xmax = 2021,
    ymin = -5]
\addplot coordinates {
    (2017, 16) (2018, 229)     (2019, 67) (2020, 130) 
    (2021, 546)
};
\addplot coordinates {
    (2017, 0.72) (2018, 74)     (2019, 14.7 ) (2020, 14.3) 
    (2021, 140)
};
\addplot coordinates {
    (2017, 0) (2018, 0.83)     (2019, 0.8 ) (2020, 2.15) 
    (2021, 51)
};

\legend{BTC, ETH, BNB}
\end{axis}
\end{tikzpicture}

答案1

只需添加一个空的千位分隔符并将 x 刻度距离设置为 1。

pgfplots x 轴上的年份

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}

\begin{document}


    \begin{tikzpicture}
    \begin{axis}[xlabel={ 1 января 2017-2021 },ylabel={Рыночная каппитализация в млрд. долларов}, legend pos = north west, table/col sep = semicolon,
        height = 0.5\paperheight, 
        width = 0.65\paperwidth,
        x tick label style={/pgf/number format/.cd,set thousands separator={}},
        xtick distance={1},
        xmin = 2017,
        xmax = 2021,
        ymin = -5]
    \addplot coordinates {
        (2017, 16) (2018, 229)     (2019, 67) (2020, 130) 
        (2021, 546)
    };
    \addplot coordinates {
        (2017, 0.72) (2018, 74)     (2019, 14.7 ) (2020, 14.3) 
        (2021, 140)
    };
    \addplot coordinates {
        (2017, 0) (2018, 0.83)     (2019, 0.8 ) (2020, 2.15) 
        (2021, 51)
    };
    
    \legend{BTC, ETH, BNB}
    \end{axis}
    \end{tikzpicture}


\end{document}

相关内容