我想了解如何将我的标签从通用标签更改(A)
为(My special label)
每个图表的单独标签,以及如何创建额外的空间,以便图表及其各自的标签不会相互冲突。这是我的代码(自动标记是我有的\nextgroupplot [auto title]
):
\documentclass[aps,amsmath,amssymb,letter,scriptaddress,twocolumn, prl,showkeys] {article}
\usepackage{amsmath}
\usepackage{amsthm}
\newtheorem{thm}{Theorem}
\usepackage{amssymb}
\usepackage{pgfplots,alphalph}
\usepgfplotslibrary{groupplots}
%\usepackage{mathtools}
%\usepackage{makeidx}
%\usepackage{amsfonts}
%\usepackage[ansinew]{inputenc}
%\usepackage[usenames,dvipsnames]{pstricks}
%\usepackage{subfigure}
%\usepackage{epsfig}
%\usepackage{pst-grad} % For gradients
%\usepackage{pst-plot} % For axes
%\usepackage[colorlinks,hyperindex]{hyperref}
\makeatletter
\newcommand{\rmnum}[1]{\romannumeral #1}
\newcommand{\Rmnum}[1]{\expandafter\@slowromancap\romannumeral #1@}
\makeatother
\makeatletter
\pgfplotsset{
auto title/.style={ title=(\AlphAlph{\pgfplots@group@current@plot})
}
}
\makeatother
\begin{document}
\begin{figure*}
\begin{tikzpicture}[font=\footnotesize\sffamily]
\begin{groupplot}[
group style={group size=3 by 2,
ylabels at=edge left
},
view={0}{90},
width=5cm,
height=5cm,
scale only axis,
xmin=0, xmax=3,
ymin=-8, ymax=0,
xlabel={x},
ylabel={$y$},
name=plot2,
unbounded coords=jump]
]
\nextgroupplot [auto title]
\addplot [only marks, mark=o, color=red,auto title] table{
1 -2.5
2 -3.3
3 -3.4
};
\addplot [domain=1:3, color=black,auto title] {-0.0538*x-2.8234};
\nextgroupplot [auto title]
\addplot [only marks, mark=o, color=red,auto title] table{
1 -2.5
2 -3.3
3 -3.4
};
\addplot [domain=1:3, color=black,auto title] {-0.0538*x-2.8234};
\nextgroupplot[auto title]
\addplot [only marks, mark=o, color=red] table{
1 -2.900422094
2 -3.244193633
3 -3.283414346
};
\addplot [domain=4:6, color=black] {-0.0333*x-3.1637};
\nextgroupplot[auto title]
\addplot [only marks, mark=o, color=red] table{
4 -4.199705078
5 -4.674163057
6 -4.674163057
};
\addplot [domain=4:6, color=black] {-0.0749*x-1.7959};
\end{groupplot}
\node (A) at ([yshift=0.5cm]group c1r1.north west) {\color{red} A};
\node (B) at ([yshift=0.5cm]group c2r1.north west) {\color{red} B};
\node (C) at ([yshift=0.5cm]group c3r1.north west) {\color{red} C};
\end{tikzpicture}
\caption{My caption}
\label{myfig}
\end{figure*}
\end{document}
答案1
auto title
您可以通过删除样式并使用title=<text>
选项来提供所需的标题\nextgroup
;使用horizontal sep
和/或vertical sep
样式group style
,您可以控制绘图之间的水平或垂直分离。一个完整的示例,具有宽大的垂直间距,仅用于说明目的:
\documentclass[aps,amsmath,amssymb,letter,scriptaddress,twocolumn, prl,showkeys] {article}
\usepackage{amsmath}
\usepackage{amsthm}
\newtheorem{thm}{Theorem}
\usepackage{amssymb}
\usepackage{pgfplots,alphalph}
\usepgfplotslibrary{groupplots}
%\usepackage{mathtools}
%\usepackage{makeidx}
%\usepackage{amsfonts}
%\usepackage[ansinew]{inputenc}
%\usepackage[usenames,dvipsnames]{pstricks}
%\usepackage{subfigure}
%\usepackage{epsfig}
%\usepackage{pst-grad} % For gradients
%\usepackage{pst-plot} % For axes
%\usepackage[colorlinks,hyperindex]{hyperref}
\makeatletter
\newcommand{\rmnum}[1]{\romannumeral #1}
\newcommand{\Rmnum}[1]{\expandafter\@slowromancap\romannumeral #1@}
\makeatother
\makeatletter
%\pgfplotsset{
%auto title/.style={ title=(\AlphAlph{\pgfplots@group@current@plot})
% }
%}
\makeatother
\begin{document}
\begin{figure*}
\begin{tikzpicture}[font=\footnotesize\sffamily]
\begin{groupplot}[
group style={group size=3 by 2,vertical sep=80pt,
ylabels at=edge left
},
view={0}{90},
width=5cm,
height=5cm,
scale only axis,
xmin=0, xmax=3,
ymin=-8, ymax=0,
xlabel={x},
ylabel={$y$},
name=plot2,
unbounded coords=jump]
]
\nextgroupplot [title=(My special title)]
\addplot [only marks, mark=o, color=red,title=(A first special title)] table{
1 -2.5
2 -3.3
3 -3.4
};
\addplot [domain=1:3, color=black] {-0.0538*x-2.8234};
\nextgroupplot [title=(Another special title)]
\addplot [only marks, mark=o, color=red] table{
1 -2.5
2 -3.3
3 -3.4
};
\addplot [domain=1:3, color=black] {-0.0538*x-2.8234};
\nextgroupplot[title=(And another special title)]
\addplot [only marks, mark=o, color=red] table{
1 -2.900422094
2 -3.244193633
3 -3.283414346
};
\addplot [domain=4:6, color=black] {-0.0333*x-3.1637};
\nextgroupplot[title=(Yet another special title)]
\addplot [only marks, mark=o, color=red] table{
4 -4.199705078
5 -4.674163057
6 -4.674163057
};
\addplot [domain=4:6, color=black] {-0.0749*x-1.7959};
\end{groupplot}
\node (A) at ([yshift=0.5cm]group c1r1.north west) {\color{red} A};
\node (B) at ([yshift=0.5cm]group c2r1.north west) {\color{red} B};
\node (C) at ([yshift=0.5cm]group c3r1.north west) {\color{red} C};
\end{tikzpicture}
\caption{My caption}
\label{myfig}
\end{figure*}
\end{document}