これを中央に配置する方法を誰か教えてくれませんか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}
最後の2つのプロットを中央に揃えたい場合は、すべてのプロットに適切な幅を指定して(どれだけシフトするかがわかるように)、次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}