
pgfplotstable を使用して、いくつかのテーブルにデータを読み込もうとしています。問題は、ファイル内のデータが、テーブルに表示したい形式とは少し異なるため、変換すると一部の行データが「欠落」することです。インターネットで調べても、うまくいく方法が見つからなかったので、ここに来ました。
説明が得意ではないので、例を挙げて説明します。私が欲しいのはこれです:
しかし、今のところ私ができることはこれだけです:
この短いデモを作成するために使用したコードは次のとおりです (すべての「pgfplotstableread」は、「pgfplotstabletranspose」を使用してファイルから同じデータを読み込むことによって置き換えられます)。
\documentclass{article}
\usepackage{booktabs}
\usepackage{pgfplotstable}
\begin{document}
\pgfkeys{/pgf/number format/.cd,fixed,precision=2}
\pgfplotstableset{%
every head row/.style={
before row={%
\toprule
\ensuremath{r_{lesion}} & \multicolumn{4}{c}{\ensuremath{E_{nom}}} \\
},
after row=\midrule
},
every last row/.style={after row=\bottomrule}
}
\pgfplotstabletypeset[
numeric type,
columns/(mm)/.style={
column type=r
}
]{
(mm) 0.32 0.56 1.80 3.20
5 0.98 1.03 1.26 1.47
10 0.84 0.95 1.44 1.74
15 0.05 0.65 1.86 2.57
20 0.03 0.52 2.13 3.19
}
\vspace{0.5in}
\pgfplotstableread{
sr esr
0.32 0.98
0.56 1.03
1.8 1.26
3.2 1.47
}\rowA
\pgfplotstableread{
sr esr
0.32 0.84
0.56 0.95
1.8 1.44
3.2 1.74
}\rowB
\pgfplotstableread{
sr esr
0.32 0.05
0.56 0.65
1.8 1.86
3.2 2.57
}\rowC
\pgfplotstableread{
sr esr
0.32 0.03
0.56 0.52
1.8 2.13
3.2 3.19
}\rowD
\pgfplotstabletranspose[columns=esr, numeric type]{\transA}{\rowA}
\pgfplotstabletranspose[columns=esr, numeric type]{\transB}{\rowB}
\pgfplotstabletranspose[columns=esr, numeric type]{\transC}{\rowC}
\pgfplotstabletranspose[columns=esr, numeric type]{\transD}{\rowD}
\pgfplotstablevertcat{\renderedTable}{\transA}
\pgfplotstablevertcat{\renderedTable}{\transB}
\pgfplotstablevertcat{\renderedTable}{\transC}
\pgfplotstablevertcat{\renderedTable}{\transD}
\pgfplotstabletypeset[
columns/colnames/.style={
numeric type,
column name={(mm)},
column type=r
},
columns/0/.style={
column name={0.32}
},
columns/1/.style={
column name={0.56}
},
columns/2/.style={
column name={1.80}
},
columns/3/.style={
column name={3.20}
}
]\renderedTable
\end{document}
「colnames」を文字列型に戻すと、「NaN」ではなく「esr」が表示されますが、ドキュメントにこれらの値を手動で入力できるようにしたいので、次のようにします。
\defineColumnOneRows{5,10,20,25}
そして、それらの値を最初の列の行に入力します。
ご協力いただけると大変ありがたく思います。ご覧いただきありがとうございます。