.tikz pgfplot을 세미 사용자 정의 스타일로 정렬

.tikz pgfplot을 세미 사용자 정의 스타일로 정렬

이전에는 이 질문에서 선택적 하위 도표가 있는 테이블에서 그래프를 정렬하고 배치하는 방법에 대해 도움을 받았습니다.입력에서 두 개의 .tikz 파일 오버레이

훌륭하게 작동했지만 스케일링 옵션을 사용하여 그래프를 축소하는 것이 마음에 들지 않았습니다. 나는 너비와 높이만 지정하고 라텍스가 글꼴 크기를 관리하도록 하는 것을 훨씬 선호합니다. 훨씬 더 일관된 기사를 만들었습니다.

따라서 그래프를 생성할 때 서문에서 일괄 너비와 높이 설정을 허용하는 스타일을 지정한 다음 아래에서 해당 그래프와 관련된 개별 항목을 편집합니다.

불행히도 이 시스템을 사용하면 정렬이 다시 중단됩니다. 서문의 모든 항목을 정의하는 사용자 정의 스타일을 사용하거나 사용자 정의 스타일을 전혀 사용하지 않고 .tikz 그림의 너비와 높이를 동일하게 설정하는 경우에만 정렬이 남아 있는 것 같습니다.

내 문제를 보여주는 전체 MWE:

\documentclass{article}
\usepackage{graphicx,array,booktabs,pgfplots}
\pgfplotsset{compat=1.9}
\usetikzlibrary{calc}

\pgfplotsset{inTable/.style={
width=4.0cm,
height=4.0cm,
}}

\newsavebox{\mybox}
\sbox{\mybox}{
\begin{tikzpicture}
\begin{axis}[inTable,
scale only axis,
xmin=1,
xmax=500,
xlabel={A},
ymin=0.5,
ymax=1,
ylabel={A}]

\addplot [color=blue,solid,line width=1.0pt,forget plot]
  table[row sep=crcr]{
10  0.7  \\
11  0.7  \\
12  0.7  \\
};
\end{axis}
\end{tikzpicture}}

\newsavebox{\myboxB}
\sbox{\myboxB}{
\begin{tikzpicture}
\begin{axis}[inTable,
scale only axis,
xmin=1,
xmax=200,
xlabel={B},
ymin=0,
ymax=3,
ylabel={B}]

\addplot [color=blue,solid,line width=1.0pt,forget plot]
  table[row sep=crcr]{
10  0.5  \\
11  0.6  \\
12  0.7  \\
};
\end{axis}
\end{tikzpicture}}

\begin{document}

\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\begin{table}[htb!]
 \centering
     \begin{tabular}{P{6.5cm} P{6.5cm}}
     \toprule
      Expt1 & Expt2\\
      \cmidrule(r){1-1}\cmidrule(l){2-2}
      \begin{tikzpicture}[baseline=(a.base)]
      \node[outer sep=0pt]  (a){\usebox{\mybox}};
       %%% Change dimensions in $(a.east)+(-0.9,0cm)$
%      \node[anchor=east,outer sep=0pt] at
%               ($(a.east)+(-0.9,0cm)$){\usebox{\mybox}};
      \end{tikzpicture}
      {\usebox{\mybox}}
      &
      {\usebox{\mybox}}
      {\usebox{\myboxB}}
      \\ \bottomrule
      \end{tabular}
      \caption{Test}
      \label{tbl:1}
\end{table}

\end{document}

정렬 불량

도움을 주시면 대단히 감사하겠습니다. 이것이 내 테이블 그래프 삽입 플로팅 프로토콜의 마지막 부분이 될 것입니다.

답변1

좋습니다. Torbjørn T에게 감사드립니다. 설명서가 제 기억을 뒤흔들었습니다.

첫째, 왼쪽 상단 그림은 실제로 환경 {tikzpicture}내부 였기 때문입니다 \begin{tikzpicture}. 오른쪽 상단 그림에서도 동일한 작업을 수행해야 했습니다. 그런 다음 [baseline, trim axis left, trim axis right]각각에 정렬 플래그 \begin{tikzpicture}(실제 문서의 .tikz 파일에서 가져온 플래그)를 추가하면 정렬이 수정됩니다.

마지막으로 플롯과 하위 플롯을 전체적으로 정렬하고 제어하는 ​​방법이 있습니다. 저를 도와주신 모든 분들께 감사드립니다.

전체 MEW:

\documentclass{article}
\usepackage{graphicx,array,booktabs,pgfplots}
\pgfplotsset{compat=1.9}
\usetikzlibrary{calc}

\pgfplotsset{inTable/.style={
width=4.0cm,
height=4.0cm, %Change these numbers to ovveride all graphs in the table sizes in the table
}}

\newsavebox{\mybox}
\sbox{\mybox}{
\begin{tikzpicture}[baseline, trim axis left, trim axis right]
\begin{axis}[inTable,
scale only axis,
baseline,
xmin=1,
xmax=500,
xlabel={A},
ymin=0.5,
ymax=1,
ylabel={A}]

\addplot [color=blue,solid,line width=1.0pt,forget plot]
  table[row sep=crcr]{
10  0.7  \\
11  0.7  \\
12  0.7  \\
};
\end{axis}
\end{tikzpicture}}

\newsavebox{\myboxB}
\sbox{\myboxB}{
\begin{tikzpicture}[baseline, trim axis left, trim axis right]
\begin{axis}[inTable,
scale only axis,
xmin=1,
xmax=200,
xlabel={B},
ymin=0,
ymax=3,
ylabel={B}]

\addplot [color=blue,solid,line width=1.0pt,forget plot]
  table[row sep=crcr]{
10  0.5  \\
11  0.6  \\
12  0.7  \\
};
\end{axis}
\end{tikzpicture}}

\begin{document}

\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\begin{table}[htb!]
 \centering
     \begin{tabular}{P{6.5cm} P{6.5cm}}
     \toprule
      Expt1 & Expt2\\
      \cmidrule(r){1-1}\cmidrule(l){2-2}
      \begin{tikzpicture}[baseline=(a.base)]
      \node[outer sep=0pt]  (a){\usebox{\mybox}};
       %%% Change dimensions in $(a.east)+(-0.9,0cm)$
%      \node[anchor=east,outer sep=0pt] at
%               ($(a.east)+(-0.9,0cm)$){\usebox{\mybox}};
      \end{tikzpicture}
      {\usebox{\mybox}}
      &
      \begin{tikzpicture}[baseline=(a.base)]
      \node[outer sep=0pt]  (a){\usebox{\mybox}};
       %%% Change dimensions in $(a.east)+(-0.9,0cm)$
%      \node[anchor=east,outer sep=0pt] at
%               ($(a.east)+(-0.9,0cm)$){\usebox{\mybox}};
      \end{tikzpicture}
      {\usebox{\myboxB}}
      \\ \bottomrule
      \end{tabular}
      \caption{Test}
      \label{tbl:1}
\end{table}

\end{document}

관련 정보