TiKz 中 groupplot 标题的位置

TiKz 中 groupplot 标题的位置

我可以自定义 s 中标题的位置tikz groupplot吗?在下面的例子中,我想将标题(a、b、c 和 d)放在axis(靠近左上角)内。

\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage{amsmath}

\usetikzlibrary{pgfplots.groupplots}


\begin{document}
\begin{tikzpicture}
\begin{groupplot}[
    group style={
        group name=my plots,
        group size=4 by 1,
        ylabels at=edge left
    },
    %footnotesize,
    %width=3cm,
    %height=7cm,
        ticks = none,
    tickpos=left,
    ytick align=outside,
    xtick align=outside,
    enlarge x limits=false,
    xlabel=$t$,
    ylabel = $y$,
    y tick label style={
        /pgf/number format/.cd,
        fixed,
        fixed zerofill,
        precision=2,
        /tikz/.cd},
        max space between ticks=2500pt,
    xmin = -.5,
    xmax = 10,
    ymin = -.5,
    ymax = 5,
]
\nextgroupplot[title=(a)]
  \addplot[domain=0:2] {1};
        \draw (axis cs:2,1) -- (axis cs:2,3.5) -- (axis cs: 5,3.5) -- (axis cs: 5,1);
        \addplot[domain=5:10] {1};
\nextgroupplot[title=(b)]
    \addplot[domain=0:2] {1};
  \addplot[domain=2:6,smooth] {-.65*(x - 2)*(x - 6) + 1};
    \addplot[domain=6:10] {1};
\nextgroupplot[title=(c)]
    \addplot[domain=0:2] {1};
        \draw (axis cs:2,1) -- (axis cs: 4.5,4) -- (axis cs:7,1);
        \addplot[domain = 7:10] {1};
\nextgroupplot[title=(d)]
        \draw[->] (axis cs:0,1) -- (axis cs:2.9,1) -- (axis cs:3,4.5) -- (axis cs: 3.1,1) -- (axis cs:10,1);
    \end{groupplot}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

我会将@ignasi 的回答放在这里,因为他将其添加为评论。

使用\pgfplotsset{every axis title/.append style={at={(0.1,0.8)}}}时可以通过改变分数来调整标签的位置。

\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage{amsmath}

\usetikzlibrary{pgfplots.groupplots}


\begin{document}

\pgfplotsset{every axis title/.append style={at={(0.1,0.8)}}}
\begin{tikzpicture}
\begin{groupplot}[
    group style={
        group name=my plots,
        group size=4 by 1,
        ylabels at=edge left
    },
    %footnotesize,
    %width=3cm,
    %height=7cm,
        ticks = none,
    tickpos=left,
    ytick align=outside,
    xtick align=outside,
    enlarge x limits=false,
    xlabel=$t$,
    ylabel = $y$,
    y tick label style={
        /pgf/number format/.cd,
        fixed,
        fixed zerofill,
        precision=2,
        /tikz/.cd},
        max space between ticks=2500pt,
    xmin = -.5,
    xmax = 10,
    ymin = -.5,
    ymax = 5,
]
\nextgroupplot[title=(a)]
  \addplot[domain=0:2] {1};
        \draw (axis cs:2,1) -- (axis cs:2,3.5) -- (axis cs: 5,3.5) -- (axis cs: 5,1);
        \addplot[domain=5:10] {1};
\nextgroupplot[title=(b)]
    \addplot[domain=0:2] {1};
  \addplot[domain=2:6,smooth] {-.65*(x - 2)*(x - 6) + 1};
    \addplot[domain=6:10] {1};
\nextgroupplot[title=(c)]
    \addplot[domain=0:2] {1};
        \draw (axis cs:2,1) -- (axis cs: 4.5,4) -- (axis cs:7,1);
        \addplot[domain = 7:10] {1};
\nextgroupplot[title=(d)]
        \draw[->] (axis cs:0,1) -- (axis cs:2.9,1) -- (axis cs:3,4.5) -- (axis cs: 3.1,1) -- (axis cs:10,1);
    \end{groupplot}
\end{tikzpicture}
\end{document}

相关内容