插入一行点来指示 pgfplotstable 中过滤掉的行

插入一行点来指示 pgfplotstable 中过滤掉的行

是否可以插入一行 $\vdots$ 来pgfplotstable指示被过滤掉的行。具体来说,请考虑以下示例:

\documentclass{article}
\usepackage{pgfplotstable}

\begin{filecontents*}{data.tsv}
iter    lambda  r1  r2  C   MSE
1   10.0    0.6710713925665714  0.9519262928278602  1.6229976853944317  7.465701425408166
2   16.229976853944315  0.6029090690580267  0.8360138028577461  1.4389228719157727  9.815864017219557
3   20.619205573102043  0.5732960789165094  0.7865138822077059  1.3598099611242151  11.263963770478508
4   24.217305184344195  0.5547236059199503  0.7557602094034712  1.3104838153234215  12.366513316823394
5   27.32214333757841   0.5414428281357702  0.7339136719411257  1.2753565000768958  13.270238586788864
6   30.07570833834737   0.5312474114501293  0.7172272338135601  1.2484746452636895  14.04091288891615
7   32.56045479098427   0.5230599389424939  0.703881780964345   1.2269417199068389  14.714802160780472
8   34.82987199005265   0.5162759672285189  0.6928616790121301  1.2091376462406491  15.314405802551722
9   36.921248452459146  0.5105238236641577  0.6835448852314608  1.1940687088956186  15.854805099298442
10  38.861935541415335  0.5055593791930413  0.6755242789783418  1.181083658171383   16.3466839321929
\end{filecontents*}

\pgfplotsset{compat=1.14}   

\begin{document}
\pgfplotstabletypeset
  [ 
    columns={iter, lambda, r1, r2},
    fixed zerofill, precision=2,
    columns/iter/.style={int detect, column name=\textsc{Iteration}},
    columns/lambda/.style={precision=3, column name=$\lambda$},
    columns/r1/.style={precision=4, column name=$r_1$},
    columns/r2/.style={precision=4, column name=$r_2$},
    skip rows between index={3}{7},
  ]{data.tsv}

\end{document}

这使

在此处输入图片描述

我已经过滤了第 4 至 7 行,我想插入

$\vdots$ & $\vdots$ & $\vdots$ & $\vdots$

表示缺少某些数据。如何在不更改原始数据文件的情况下做到这一点?

答案1

过滤出第 5 至第 7 行,并使用 $\vdots$ 替换第 4 行(即行索引=3)单元格的内容

postproc cell content/.append code={%
  \ifnum\pgfplotstablerow=3
    \pgfkeyssetvalue{/pgfplots/table/@cell content}{\ensuremath{\vdots}}%
  \fi
}

在此处输入图片描述

代码:

\documentclass{article}
\usepackage{pgfplotstable}

\begin{filecontents*}{data.tsv}
iter    lambda  r1  r2  C   MSE
1   10.0    0.6710713925665714  0.9519262928278602  1.6229976853944317  7.465701425408166
2   16.229976853944315  0.6029090690580267  0.8360138028577461  1.4389228719157727  9.815864017219557
3   20.619205573102043  0.5732960789165094  0.7865138822077059  1.3598099611242151  11.263963770478508
4   24.217305184344195  0.5547236059199503  0.7557602094034712  1.3104838153234215  12.366513316823394
5   27.32214333757841   0.5414428281357702  0.7339136719411257  1.2753565000768958  13.270238586788864
6   30.07570833834737   0.5312474114501293  0.7172272338135601  1.2484746452636895  14.04091288891615
7   32.56045479098427   0.5230599389424939  0.703881780964345   1.2269417199068389  14.714802160780472
8   34.82987199005265   0.5162759672285189  0.6928616790121301  1.2091376462406491  15.314405802551722
9   36.921248452459146  0.5105238236641577  0.6835448852314608  1.1940687088956186  15.854805099298442
10  38.861935541415335  0.5055593791930413  0.6755242789783418  1.181083658171383   16.3466839321929
\end{filecontents*}

\pgfplotsset{compat=1.14}   

\begin{document}
\pgfplotstabletypeset
  [ 
    columns={iter, lambda, r1, r2},
    fixed zerofill, precision=2,
    columns/iter/.style={int detect, column name=\textsc{Iteration}},
    columns/lambda/.style={precision=3, column name=$\lambda$},
    columns/r1/.style={precision=4, column name=$r_1$},
    columns/r2/.style={precision=4, column name=$r_2$},
    skip rows between index={4}{7},
    postproc cell content/.append code={%
      \ifnum\pgfplotstablerow=3
        \pgfkeyssetvalue{/pgfplots/table/@cell content}{\ensuremath{\vdots}}%
      \fi
    }
  ]{data.tsv}
\end{document}

相关内容