为什么最后一个 pgfplots 刻度标签没有显示在我的其中一个组图中?

为什么最后一个 pgfplots 刻度标签没有显示在我的其中一个组图中?

这让我很抓狂。为什么最后一个刻度标签只显示在其中一个组图中,尽管它们的定义相同?如果绘制单个图,也不会显示它。

代码:

\documentclass[12pt]{standalone}
\usepackage{filecontents}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.groupplots}

\begin{document}

\begin{filecontents*}{data.csv}
ratio,1545ARI,1545IU,2575ARI,2575IU,3595ARI,3595IU
0.5,0.46781,0.55161,0.46235,0.54209,0.45536,0.53538
1.0,0.47004,0.55282,0.46525,0.54487,0.45885,0.53718
1.5,0.47076,0.55349,0.46685,0.54560,0.46029,0.53768
2.0,0.47158,0.55442,0.46913,0.54762,0.46223,0.53996
2.5,0.47227,0.55495,0.47136,0.54886,0.46471,0.54096
3.0,0.47239,0.55517,0.47286,0.55009,0.46665,0.54256
3.5,0.47349,0.55604,0.47388,0.55170,0.46699,0.54300
4.0,0.47342,0.55621,0.47543,0.55287,0.46805,0.54367
4.5,0.47407,0.55643,0.47660,0.55376,0.46836,0.54454
5.0,0.47422,0.55668,0.47563,0.55342,0.47097,0.54620
5.5,0.47431,0.55688,0.47651,0.55385,0.47169,0.54682
6.0,0.47393,0.55679,0.47675,0.55470,0.47298,0.54814
6.5,0.47485,0.55727,0.47660,0.55468,0.47375,0.54848
7.0,0.47476,0.55734,0.47773,0.55550,0.47487,0.54872
7.5,0.47484,0.55737,0.47822,0.55578,0.47604,0.54919
8.0,0.47472,0.55750,0.47790,0.55572,0.47564,0.54941
8.5,0.47512,0.55784,0.47831,0.55654,0.47657,0.54992
9.0,0.47530,0.55762,0.47932,0.55683,0.47606,0.54990
\end{filecontents*}

\begin{tikzpicture}[font=\small]
\begin{groupplot}[
    group style={rows=1,columns=2,horizontal sep=2cm},
    height=7cm, width=7cm,
    grid,
    yticklabel style={/pgf/number format/fixed,
                      /pgf/number format/precision=3,
                      /pgf/number format/zerofill},
    ]
\nextgroupplot[
        ytick={0.535,0.54,...,0.56},
        ymin=0.535,ymax=0.56,xmin=0,xmax=10]
    \addplot table [col sep=comma,x=ratio,y=2575IU] {data.csv};
    \addplot table [col sep=comma,x=ratio,y=3595IU] {data.csv}; 
    \addplot table [col sep=comma,x=ratio,y=1545IU] {data.csv};
\nextgroupplot[
        ytick={0.455,0.46,...,0.485},
        ymin=0.455,ymax=0.485,xmin=0,xmax=10]
    \addplot table [col sep=comma,x=ratio,y=1545ARI] {data.csv};
    \addplot table [col sep=comma,x=ratio,y=2575ARI] {data.csv};
    \addplot table [col sep=comma,x=ratio,y=3595ARI] {data.csv};
\end{groupplot}

\end{tikzpicture}
\end{document}

结果: 在此处输入图片描述

答案1

这是数值不一致和自动调整大小的结合。foreach 语法使用 TikZ 后端,由于其实现,如果步长受到数值噪声的影响,它可能无法达到最后一个点。此外,您正在对刻度位置进行修剪,因此ymax也需要微调。因此,对于左边的浮点表示更好,但右边的浮点表示则出错了。

使用稍微调整的选项会显示缺失的勾号:

    ytick={0.455,0.46,...,0.48505},
    ymin=0.455,ymax=0.48505,

相关内容