TikZ: tikzpicture에 사용되는 경우 특정 테이블을 \pgfplotstableset에 전달하는 방법

TikZ: tikzpicture에 사용되는 경우 특정 테이블을 \pgfplotstableset에 전달하는 방법

내가 원하는 작업을 수행하는 것처럼 보이는 다음 코드를 만들었습니다. 즉, \IDA4개 값의 평균인 추가 행을 테이블에 추가합니다 . 그런 다음 이 행을 의 플롯에 사용할 수 있습니다 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}

그러나 여러 테이블/그림에 대해 이 작업을 수행해야 하므로 어떻게든 두 명령을 하나로 결합하거나 적어도 위의 내용이 \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}

여기에 이미지 설명을 입력하세요

관련 정보