누구든지 이것을 중앙에 맞추는 방법을 보여줄 수 있습니까 group plot
? 나는 유사한 게시물이 있는 tex.stackexchange 책에 있는 모든 트릭을 시도했습니다(예:LaTeX에서 큰 그림을 중앙에 배치하는 방법과 짧은 정렬 선을 수정하는 방법은 무엇입니까?).
\documentclass[]{article}
\usepackage{pgfplots, alphalph}
\usepgfplotslibrary{groupplots}
\begin{document}
\begin{figure}
\begin{tikzpicture}[font=\footnotesize\sffamily]
\begin{groupplot}[
group style={group size=3 by 2, vertical sep=70pt,
ylabels at=edge left
},
view={0}{90},
width=5.2cm,
height=5.2cm,
scale only axis,
scaled ticks = false,
tick label style={/pgf/number format/fixed},
title={My title},
xlabel={x-axis},
ylabel={y-axis}],
unbounded coords=jump]
]
\nextgroupplot [title={\it{Title 1}}]
\addplot[black, thick, mark=o, only marks]
coordinates {
};
\nextgroupplot [title={\it{Title 2}}]
\addplot[black, thick, mark=o, only marks]
coordinates {
};
\nextgroupplot [title={\it{Title 3}}]
\addplot[black, thick, mark=o, only marks]
coordinates {
};
\nextgroupplot [title={\it{Title 4}}]
\addplot[black, thick, mark=o, only marks]
coordinates {
};
\nextgroupplot [title={\it{Title 5}}]
\addplot[black, thick, mark=o, only marks]
coordinates {
};
\end{groupplot}
\end{tikzpicture}
\end{figure}
\end{document}
답변1
토지가 너무 넓습니다. 3개 대신 2개의 플롯을 연속으로 배치하려고 시도할 수 있습니다. 그러나 항상 사용할 수 있는 이 상자 기술이 있습니다.
\documentclass[]{article}
\usepackage{pgfplots, alphalph}
\usepgfplotslibrary{groupplots}
\begin{document}
\begin{figure}
\makebox[\textwidth]{%
\begin{tikzpicture}[font=\footnotesize\sffamily]
\begin{groupplot}[
group style={group size=3 by 2, vertical sep=70pt,
ylabels at=edge left
},
view={0}{90},
width=5.2cm,
height=5.2cm,
scale only axis,
scaled ticks = false,
tick label style={/pgf/number format/fixed},
title={My title},
xlabel={x-axis},
ylabel={y-axis}],
unbounded coords=jump]
]
\nextgroupplot [title={\it{Title 1}}]
\addplot[black, thick, mark=o, only marks]
coordinates {
};
\nextgroupplot [title={\it{Title 2}}]
\addplot[black, thick, mark=o, only marks]
coordinates {
};
\nextgroupplot [title={\it{Title 3}}]
\addplot[black, thick, mark=o, only marks]
coordinates {
};
\nextgroupplot [title={\it{Title 4}}]
\addplot[black, thick, mark=o, only marks]
coordinates {
};
\nextgroupplot [title={\it{Title 5}}]
\addplot[black, thick, mark=o, only marks]
coordinates {
};
\end{groupplot}
\end{tikzpicture}
}
\end{figure}
\end{document}
경우에 따라 마지막 두 플롯을 중앙에 배치하려는 경우 모든 플롯에 적합한 너비를 사용하여(이동할 정도를 알 수 있도록) 다음 xshift
과 같이 사용할 수 있습니다.
\nextgroupplot [xshift=1.2in,title={\it{Title 4}}]
\addplot[black, thick, mark=o, only marks]
coordinates {
};
\nextgroupplot [xshift=1.2in,title={\it{Title 5}}]
\addplot[black, thick, mark=o, only marks]
coordinates {
};
와 함께 table
:
\documentclass[]{article}
\usepackage{pgfplots, alphalph}
\usepgfplotslibrary{groupplots}
\usepackage{filecontents}
\begin{filecontents*}{mydata.dat}
A B
1 4
2 6
3 9
4 2
5 3
\end{filecontents*}
\begin{document}
\begin{figure}
\makebox[\textwidth]{%
\begin{tikzpicture}[font=\footnotesize\sffamily]
\begin{groupplot}[
group style={group size=3 by 2, vertical sep=70pt,
ylabels at=edge left
},
view={0}{90},
width=5.2cm,
height=5.2cm,
scale only axis,
scaled ticks = false,
tick label style={/pgf/number format/fixed},
title={My title},
xlabel={x-axis},
ylabel={y-axis}],
unbounded coords=jump]
]
\nextgroupplot [title={\it{Title 1}}]
\addplot[black, thick, mark=o, only marks]
table[x=A,y=B]{mydata.dat};
\nextgroupplot [title={\it{Title 2}}]
\addplot[black, thick, mark=o, only marks]
table[x=A,y=B]{mydata.dat};
\nextgroupplot [title={\it{Title 3}}]
\addplot[black, thick, mark=o, only marks]
table[x=A,y=B]{mydata.dat};
\nextgroupplot [title={\it{Title 4}}]
\addplot[black, thick, mark=o, only marks]
table[x=A,y=B]{mydata.dat};
\nextgroupplot [title={\it{Title 5}}]
\addplot[black, thick, mark=o, only marks]
table[x=A,y=B]{mydata.dat};
\end{groupplot}
\end{tikzpicture}
}
\end{figure}
\end{document}
그리고
\nextgroupplot [xshift=1.2in,title={\it{Title 4}}]
\addplot[black, thick, mark=o, only marks]
table[x=A,y=B]{mydata.dat};
\nextgroupplot [xshift=1.2in,title={\it{Title 5}}]
\addplot[black, thick, mark=o, only marks]
table[x=A,y=B]{mydata.dat};
답변2
또 다른 대안: 추가 \hspace*{-4cm}
(좋은 센터링을 달성하기 위해 몇 센티미터를 조정). 예를 들어:
\documentclass[]{article}
\usepackage{pgfplots, alphalph}
\usepgfplotslibrary{groupplots}
\begin{document}
\begin{figure}
\hspace*{-4cm}
\begin{tikzpicture}[font=\footnotesize\sffamily]
\begin{groupplot}[
group style={group size=3 by 2, vertical sep=70pt,
ylabels at=edge left
},
view={0}{90},
width=5.2cm,
height=5.2cm,
scale only axis,
scaled ticks = false,
tick label style={/pgf/number format/fixed},
title={My title},
xlabel={x-axis},
ylabel={y-axis}],
unbounded coords=jump]
]
\nextgroupplot [title={\it{Title 1}}]
\addplot[black, thick, mark=o, only marks]
coordinates {
};
\nextgroupplot [title={\it{Title 2}}]
\addplot[black, thick, mark=o, only marks]
coordinates {
};
\nextgroupplot [title={\it{Title 3}}]
\addplot[black, thick, mark=o, only marks]
coordinates {
};
\nextgroupplot [title={\it{Title 4}}]
\addplot[black, thick, mark=o, only marks]
coordinates {
};
\nextgroupplot [title={\it{Title 5}}]
\addplot[black, thick, mark=o, only marks]
coordinates {
};
\end{groupplot}
\end{tikzpicture}
\end{figure}
\end{document}