
私が望んでいることを実行すると思われる次のコードを作成しました。つまり、\IDA
4 つの値の平均である行をテーブルに追加します。この行は、 のプロットに使用できますtikzpicture
。
\documentclass[tikz]{standalone}
\usepackage{filecontents}
\usepackage{pgfplots, pgfplotstable}
\begin{filecontents}{FileA.dat}
step ts1 ts2
1 3 4
2 7 6
3 4 6
4 5 6
5 5 7
6 9 3
\end{filecontents}
\begin{filecontents}{FileB.dat}
step tHIws
1 3
2 7
3 4
4 5
5 5
6 9
\end{filecontents}
% for calculations
\pgfplotstableread{FileB.dat}\SST
\pgfplotstableread{FileA.dat}\IDA
\pgfplotstableset{
create on use/tHIws/.style={
create col/expr={\thisrow{ts1}+\thisrow{ts2})/2}
}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis x line=bottom,
axis y line=left,
tick align=outside,
xlabel=\texttt{step},
ylabel={$\theta_{a}$},
legend pos= north west,
legend columns=6,
legend style={fill=none, draw=none},
cycle multi list={
color list%
},
ymajorgrids,
]
\addplot table
[x=step, y=tHIws]
{\SST};
\addlegendentry{SSTe}
\addplot +[mark=*] table
[x=step, y=tHIws]
{\IDA};
\addlegendentry{IDA}
\addplot table
[x=step, y expr=(\thisrow{ts1}+\thisrow{ts2})/2]
{FileA.dat};
\addlegendentry{IDA}
\end{axis}
\end{tikzpicture}
\end{document}
ただし、多数の表や図に対してこれを行う必要があるため、何らかの方法で 2 つのコマンドを 1 つに結合するか、少なくとも上記が\pgfplotstableset
表にのみ適用されるようにしたいと考えています\IDA
。
これを実行する方法はありますか?
percusse の回答により編集しました。実際に tikxpictures に転送しようとしましたが、これまで失敗しました。
編集2: 完全な例!
編集 3: 内部データが追加されました。しかし、コンパイル時にエラーが発生します: 「テーブル 'FileA.dat' から列 'step' を取得できませんでした。」 しかし、エラーが見つからないようです。私は「Betriebsblind」なのでしょう。
編集4: インラインファイルコンテンツに不足していたusepackageを追加しました
答え1
編集に関しては、表現をスタイルに配置して、必要なときにいつでも適用する方が簡単です。ここでは、mymedian
\documentclass{standalone}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.10}
\pgfplotstableread{
step ts1 ts2 ts3 ts4
1 3 4 11 14
2 7 6 22 26
3 4 6 34 31
4 5 6 45 46
5 5 7 55 57
6 9 3 69 63
}\SST
% for calculations
\pgfplotsset{mymedian/.style={
x=step, y expr=(\thisrow{ts1}+\thisrow{ts2}+\thisrow{ts3}+\thisrow{ts4})/4
}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis x line=bottom,
axis y line=left,
tick align=outside,
xlabel=\texttt{step},
ylabel={$\theta_{a}$},
legend pos= north west,
legend columns=6,
legend style={fill=none, draw=none},
cycle multi list={
color list%
},
ymajorgrids,
]
\addplot table[mymedian] {\SST};
\addlegendentry{SSTmean}
\addplot table[x=step,y=ts3] {\SST};
\addlegendentry{SSTS3}
\end{axis}
\end{tikzpicture}
\end{document}