
많은 열이 포함된 데이터 파일이 있고 n=2에 대해 bwgstar 대 서버를 표시하려고 합니다. 따라서 n은 메타 열이고, 서버는 x축에, bwgstar는 y축에 있습니다. 나중에 데이터를 다시 생성할 수 있도록 라텍스 문서 내에서 이 작업을 수행하고 싶습니다.
일부 데이터의 단축 버전이 아래에 표시됩니다.
k n servers switches degree diameter bwg bwgstar difference t
2 2 8 4 2 4 2 2 0 1
2 3 36 9 4 5 8 6 2 3
2 4 96 16 6 5 16 16 0 8
2 5 200 25 8 5 36 30 6 10
2 6 360 36 10 5 54 54 0 13
2 7 588 49 12 5 96 84 12 21
3 2 24 8 3 6 4 4 0 4
3 3 162 27 6 7 26 22 4 10
3 4 576 64 9 7 64 64 0 32
답변1
다음과 같은 접근 방식을 적용할 수 있습니다.테이블에서 행 필터링:
\documentclass[border=5mm]{standalone}
\usepackage{filecontents}
\usepackage{pgfplots}
\pgfplotsset{
discard if not/.style 2 args={
x filter/.code={
\ifnum\thisrow{#1}=#2
\else
\def\pgfmathresult{nan}
\fi
}
}
}
\begin{filecontents}{data.dat}
k n servers switches degree diameter bwg bwgstar difference t
2 2 8 4 2 4 2 2 0 1
2 3 36 9 4 5 8 6 2 3
2 4 96 16 6 5 16 16 0 8
2 5 200 25 8 5 36 30 6 10
2 6 360 36 10 5 54 54 0 13
2 7 588 49 12 5 96 84 12 21
3 2 24 8 3 6 4 4 0 4
3 3 162 27 6 7 26 22 4 10
3 4 576 64 9 7 64 64 0 32
\end{filecontents}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot [only marks] table [x=bwgstar, y=servers, discard if not={n}{2}] {data.dat};
\end{axis}
\end{tikzpicture}
\end{document}