如何创建子图、添加图例、删除 1000 个分隔符以及添加标题?

如何创建子图、添加图例、删除 1000 个分隔符以及添加标题?

我有 8 张 tikzpicture,需要将它们合并成一张适合 A4 纸大小的图片,这样顶行有 3 张图,第二行有 3 张图,底行有 2 张图。底行的图也应居中。

另外,我想知道如何删除 1,000 个逗号分隔符,以便显示“2000”而不是“2,000”。

我还想为所有图表添加一个位于图表下方的标题。

最后,我还想为整个图形添加一个标题。

这是我目前拥有的代码:

\documentclass[11pt]{report}
\usepackage{tikz}
\usepackage{pgfplots}    
\begin{document}        
    \begin{tikzpicture}
        \begin{axis}[
            title={Cluster 0},
            xlabel={Year},
            ylabel={},
            xmin=2000, xmax=2020,
            ymin=0, ymax=2,
            xtick={2000,2005,2010,2015,2020},
            ytick={0,0.25,.5,.75,1,1.25,1.5,1.75,2},
            legend pos=north west,
            ymajorgrids=true,
            grid style=dashed,
        ]
        
        \addplot[
            color=blue,
            mark=square,
            ]
            coordinates {
            (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)(2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0)(2019,0)(2020,0)
            };
        
        \addplot[
            color=red,
            mark=square,
            ]
            coordinates{
            (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)(2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0)(2019,0)(2020,0)
            };
            \legend{Acquisition, Divestment, yo}
        
        \end{axis}
        
        \end{tikzpicture}
        \begin{tikzpicture}
        \begin{axis}[
            title={Cluster 1},
            xlabel={Year},
            ylabel={},
            xmin=2000, xmax=2020,
            ymin=0, ymax=2,
            xtick={2000,2005,2010,2015,2020},
            ytick={0,0.25,.5,.75,1,1.25,1.5,1.75,2},
            legend pos=north west,
            ymajorgrids=true,
            grid style=dashed,
        ]
        
        \addplot[
            color=blue,
            mark=square,
            ]
            coordinates {
            (2000,1.604166667)(2001,0.260416667)(2002,0.104166667)(2003,0.09375)(2004,0.270833333)(2005,0.15625)(2006,0.28125)(2007,0.09375)(2008,0.104166667)(2009,0.104166667)(2010,0.072916667)(2011,0.104166667)(2012,0.052083333)(2013,0.083333333)(2014,0.041666667)(2015,0.020833333)(2016,0.0625)(2017,0.0625)(2018,0.041666667)(2019,0.104166667)(2020,0.03125)
            };
        
        \addplot[
            color=red,
            mark=square,
            ]
            coordinates{
            (2000,0)(2001,0)(2002,0.010416667)(2003,0.041666667)(2004,0)(2005,0)(2006,0.020833333)(2007,0.020833333)(2008,0)(2009,0)(2010,0.010416667)(2011,0.010416667)(2012,0.03125)(2013,0.03125)(2014,0)(2015,0.03125)(2016,0.020833333)(2017,0)(2018,0)(2019,0)(2020,0.010416667)
            };
            \legend{Acquisition, Divestment, yo}
        
        \end{axis}
        
        \end{tikzpicture}
        \begin{tikzpicture}
        \begin{axis}[
            title={Cluster 2},
            xlabel={Year},
            ylabel={},
            xmin=2000, xmax=2020,
            ymin=0, ymax=0.2,
            xtick={2000,2005,2010,2015,2020},
            ytick={0,0.05,.1,.15,.2},
            legend pos=north west,
            ymajorgrids=true,
            grid style=dashed,
        ]
        
        \addplot[
            color=blue,
            mark=square,
            ]
            coordinates {
            (2000,0.063683305)(2001,0.076592083)(2002,0.083476764)(2003,0.070567986)(2004,0.081755594)(2005,0.092943201)(2006,0.098106713)(2007,0.139414802)(2008,0.111876076)(2009,0.089500861)(2010,0.100688468)(2011,0.096385542)(2012,0.093803787)(2013,0.081755594)(2014,0.102409639)(2015,0.06626506)(2016,0.100688468)(2017,0.090361446)(2018,0.080895009)(2019,0.06454389)(2020,0.048192771)
            };
        
        \addplot[
            color=red,
            mark=square,
            ]
            coordinates{
            (2000,0.024956971)(2001,0.022375215)(2002,0.009466437)(2003,0.012048193)(2004,0.008605852)(2005,0.030981067)(2006,0.017211704)(2007,0.016351119)(2008,0.015490534)(2009,0.014629948)(2010,0.020654045)(2011,0.01979346)(2012,0.0232358)(2013,0.010327022)(2014,0.018072289)(2015,0.020654045)(2016,0.017211704)(2017,0.014629948)(2018,0.015490534)(2019,0.016351119)(2020,0.010327022)
            };
            \legend{Acquisition, Divestment, yo}
        
        \end{axis}
        
        \end{tikzpicture}
        \begin{tikzpicture}
        \begin{axis}[
            title={Cluster 3},
            xlabel={Year},
            ylabel={},
            xmin=2000, xmax=2020,
            ymin=0, ymax=1.5,
            xtick={2000,2005,2010,2015,2020},
            ytick={0,0.25,.5,.75,1,1.25,1.5},
            legend pos=north west,
            ymajorgrids=true,
            grid style=dashed,
        ]
        
        \addplot[
            color=blue,
            mark=square,
            ]
            coordinates {
            (2000,0)(2001,0)(2002,0)(2003,0.012658228)(2004,0.050632911)(2005,0)(2006,0.012658228)(2007,0.012658228)(2008,0.012658228)(2009,0.037974684)(2010,0.050632911)(2011,0)(2012,0.050632911)(2013,0.025316456)(2014,0.227848101)(2015,1.316455696)(2016,0.126582278)(2017,0.063291139)(2018,0.113924051)(2019,0.037974684)(2020,0.012658228)
            };
        
        \addplot[
            color=red,
            mark=square,
            ]
            coordinates{
            (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)(2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0.012658228)(2018,0)(2019,0)(2020,0)
            };
            \legend{Acquisition, Divestment, yo}
        
        \end{axis}
        
        \end{tikzpicture}
        \begin{tikzpicture}
        \begin{axis}[
            title={Cluster 4},
            xlabel={Year},
            ylabel={},
            xmin=2000, xmax=2020,
            ymin=0, ymax=2.25,
            xtick={2000,2005,2010,2015,2020},
            ytick={0,0.25,.5,.75,1,1.25,1.5,1.75,2, 2.25},
            legend pos=north west,
            ymajorgrids=true,
            grid style=dashed,
        ]
        
        \addplot[
            color=blue,
            mark=square,
            ]
            coordinates {
            (2000,1)(2001,2.043478261)(2002,0.739130435)(2003,1.130434783)(2004,0.695652174)(2005,0.913043478)(2006,0.608695652)(2007,0.782608696)(2008,0.47826087)(2009,0.47826087)(2010,0.260869565)(2011,0.608695652)(2012,0.782608696)(2013,0.217391304)(2014,0.391304348)(2015,0.52173913)(2016,0.304347826)(2017,0.130434783)(2018,0.434782609)(2019,0.130434783)(2020,0.130434783)
            };
        
        \addplot[
            color=red,
            mark=square,
            ]
            coordinates{
            (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0.043478261)(2006,0.173913043)(2007,0.086956522)(2008,0)(2009,0)(2010,0)(2011,0)(2012,0)(2013,0)(2014,0)(2015,0.086956522)(2016,0.043478261)(2017,0)(2018,0.086956522)(2019,0.043478261)(2020,0)
            };
            \legend{Acquisition, Divestment, yo}
        
        \end{axis}
        
        \end{tikzpicture}
        \begin{tikzpicture}
        \begin{axis}[
            title={Cluster 5},
            xlabel={Year},
            ylabel={},
            xmin=2000, xmax=2020,
            ymin=0, ymax=6.5,
            xtick={2000,2005,2010,2015,2020},
            ytick={0,0.25,.5,.75,1,1.25,1.5,1.75,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5},
            legend pos=north west,
            ymajorgrids=true,
            grid style=dashed,
        ]
        
        \addplot[
            color=blue,
            mark=square,
            ]
            coordinates {
            (2000,6)(2001,1.333333333)(2002,0.888888889)(2003,1)(2004,2.333333333)(2005,2.111111111)(2006,0.777777778)(2007,1.111111111)(2008,0.777777778)(2009,0.222222222)(2010,0.777777778)(2011,0.666666667)(2012,0.111111111)(2013,0.444444444)(2014,0.111111111)(2015,0.222222222)(2016,0.111111111)(2017,0.111111111)(2018,0.222222222)(2019,0)(2020,0.111111111)
            };
        
        \addplot[
            color=red,
            mark=square,
            ]
            coordinates{
            (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)(2011,0.111111111)(2012,0)(2013,0)(2014,0)(2015,0.222222222)(2016,0)(2017,0)(2018,0.111111111)(2019,0)(2020,0)
            };
            \legend{Acquisition, Divestment, yo}
        
        \end{axis}
        
        \end{tikzpicture}
        \begin{tikzpicture}
        \begin{axis}[
            title={Cluster 6},
            xlabel={Year},
            ylabel={},
            xmin=2000, xmax=2020,
            ymin=0, ymax=2,
            xtick={2000,2005,2010,2015,2020},
            ytick={0,0.25,.5,.75,1,1.25,1.5,1.75,2},
            legend pos=north west,
            ymajorgrids=true,
            grid style=dashed,
        ]
        
        \addplot[
            color=blue,
            mark=square,
            ]
            coordinates {
            (2000,1.4)(2001,1.2)(2002,0.2)(2003,2.8)(2004,2)(2005,1.8)(2006,3)(2007,3.6)(2008,1.8)(2009,1)(2010,1.2)(2011,2.6)(2012,1)(2013,1.4)(2014,1)(2015,1.8)(2016,0.6)(2017,0.8)(2018,1.8)(2019,0.4)(2020,0.4)
            };
        
        \addplot[
            color=red,
            mark=square,
            ]
            coordinates{
            (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)(2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0.2)(2019,0.2)(2020,0)
            };
            \legend{Acquisition, Divestment, yo}
        
        \end{axis}
        
        \end{tikzpicture}
        \begin{tikzpicture}
        \begin{axis}[
            title={Cluster 7},
            xlabel={Year},
            ylabel={},
            xmin=2000, xmax=2020,
            ymin=0, ymax=10,
            xtick={2000,2005,2010,2015,2020},
            ytick={0,1,2,3,4,5,6,7,8,9,10},
            legend pos=north west,
            ymajorgrids=true,
            grid style=dashed,
        ]
        
        \addplot[
            color=blue,
            mark=square,
            ]
            coordinates {
            (2000,4)(2001,4)(2002,9)(2003,5)(2004,6)(2005,4)(2006,1)(2007,0)(2008,2)(2009,0)(2010,0)(2011,1)(2012,1)(2013,0)(2014,0)(2015,1)(2016,2)(2017,0)(2018,0)(2019,0)(2020,0)
            };
        
        \addplot[
            color=red,
            mark=square,
            ]
            coordinates{
            (2000,0)(2001,5)(2002,0)(2003,0)(2004,0)(2005,5)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)(2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0)(2019,0)(2020,0)
            };
            \legend{Acquisition, Divestment, yo}
        
        \end{axis}
        \end{tikzpicture}
    \end{document}

有人能帮我解决这个问题吗?提前谢谢!

答案1

正如您所问,这是一个解决方案。但是我仍然认为您可以将它们分成不同的页面。图表会更大,更易读。

\documentclass[11pt,a4paper]{report}
\usepackage{geometry}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\pgfkeys{
/pgf/number format/.cd,1000 sep={},
}
\usepackage{subfig}
\begin{document}
\listoffigures
\clearpage
\newgeometry{margin=0cm}
\begin{figure}[ht]
\centering
\small
\subfloat[caption 1]{
\begin{tikzpicture}
\begin{axis}[
        height=0.2\paperheight,    
        title={Cluster 0},
        xlabel={Year},
        ylabel={},
        xmin=2000, xmax=2020,
        ymin=0, ymax=2,
        xtick={2000,2005,2010,2015,2020},
        ytick={0,0.25,.5,.75,1,1.25,1.5,1.75,2},
        legend pos=north west,
        legend to name=outsidelegend,
        ymajorgrids=true,
        grid style=dashed,
    ]
    
    \addplot[
        color=blue,
        mark=square,
        ]
        coordinates {
        (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)(2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0)(2019,0)(2020,0)
        };
    
    \addplot[
        color=red,
        mark=square,
        ]
        coordinates{
        (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)(2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0)(2019,0)(2020,0)
        };
        \legend{Acquisition, Divestment, yo}
    
\end{axis}
\end{tikzpicture}}
\subfloat[caption 2]{
\begin{tikzpicture}
    \begin{axis}[
        height=0.2\paperheight,
        title={Cluster 1},
        xlabel={Year},
        ylabel={},
        xmin=2000, xmax=2020,
        ymin=0, ymax=2,
        xtick={2000,2005,2010,2015,2020},
        ytick={0,0.25,.5,.75,1,1.25,1.5,1.75,2},
        ymajorgrids=true,
        grid style=dashed,
    ]
    
    \addplot[
        color=blue,
        mark=square,
        ]
        coordinates {
        (2000,1.604166667)(2001,0.260416667)(2002,0.104166667)(2003,0.09375)(2004,0.270833333)(2005,0.15625)(2006,0.28125)(2007,0.09375)(2008,0.104166667)(2009,0.104166667)(2010,0.072916667)(2011,0.104166667)(2012,0.052083333)(2013,0.083333333)(2014,0.041666667)(2015,0.020833333)(2016,0.0625)(2017,0.0625)(2018,0.041666667)(2019,0.104166667)(2020,0.03125)
        };
    
    \addplot[
        color=red,
        mark=square,
        ]
        coordinates{
        (2000,0)(2001,0)(2002,0.010416667)(2003,0.041666667)(2004,0)(2005,0)(2006,0.020833333)(2007,0.020833333)(2008,0)(2009,0)(2010,0.010416667)(2011,0.010416667)(2012,0.03125)(2013,0.03125)(2014,0)(2015,0.03125)(2016,0.020833333)(2017,0)(2018,0)(2019,0)(2020,0.010416667)
        };
    
\end{axis}
\end{tikzpicture}}
\subfloat[caption 3]{
\begin{tikzpicture}
    \begin{axis}[
        height=0.2\paperheight,
        title={Cluster 2},
        xlabel={Year},
        ylabel={},
        xmin=2000, xmax=2020,
        ymin=0, ymax=0.2,
        xtick={2000,2005,2010,2015,2020},
        ytick={0,0.05,.1,.15,.2},
        ymajorgrids=true,
        grid style=dashed,
    ]
    
    \addplot[
        color=blue,
        mark=square,
        ]
        coordinates {
        (2000,0.063683305)(2001,0.076592083)(2002,0.083476764)(2003,0.070567986)(2004,0.081755594)(2005,0.092943201)(2006,0.098106713)(2007,0.139414802)(2008,0.111876076)(2009,0.089500861)(2010,0.100688468)(2011,0.096385542)(2012,0.093803787)(2013,0.081755594)(2014,0.102409639)(2015,0.06626506)(2016,0.100688468)(2017,0.090361446)(2018,0.080895009)(2019,0.06454389)(2020,0.048192771)
        };
    
    \addplot[
        color=red,
        mark=square,
        ]
        coordinates{
        (2000,0.024956971)(2001,0.022375215)(2002,0.009466437)(2003,0.012048193)(2004,0.008605852)(2005,0.030981067)(2006,0.017211704)(2007,0.016351119)(2008,0.015490534)(2009,0.014629948)(2010,0.020654045)(2011,0.01979346)(2012,0.0232358)(2013,0.010327022)(2014,0.018072289)(2015,0.020654045)(2016,0.017211704)(2017,0.014629948)(2018,0.015490534)(2019,0.016351119)(2020,0.010327022)
        };
\end{axis}
\end{tikzpicture}}\\[10pt]
\subfloat[caption 4]{
\begin{tikzpicture}
    \begin{axis}[
        height=0.2\paperheight,
        title={Cluster 3},
        xlabel={Year},
        ylabel={},
        xmin=2000, xmax=2020,
        ymin=0, ymax=1.5,
        xtick={2000,2005,2010,2015,2020},
        ytick={0,0.25,.5,.75,1,1.25,1.5},
        ymajorgrids=true,
        grid style=dashed,
    ]
    
    \addplot[
        color=blue,
        mark=square,
        ]
        coordinates {
        (2000,0)(2001,0)(2002,0)(2003,0.012658228)(2004,0.050632911)(2005,0)(2006,0.012658228)(2007,0.012658228)(2008,0.012658228)(2009,0.037974684)(2010,0.050632911)(2011,0)(2012,0.050632911)(2013,0.025316456)(2014,0.227848101)(2015,1.316455696)(2016,0.126582278)(2017,0.063291139)(2018,0.113924051)(2019,0.037974684)(2020,0.012658228)
        };
    
    \addplot[
        color=red,
        mark=square,
        ]
        coordinates{
        (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)(2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0.012658228)(2018,0)(2019,0)(2020,0)
        };
\end{axis}
\end{tikzpicture}}
\subfloat[caption 5]{
\begin{tikzpicture}
\begin{axis}[
        height=0.2\paperheight,
        title={Cluster 4},
        xlabel={Year},
        ylabel={},
        xmin=2000, xmax=2020,
        ymin=0, ymax=2.25,
        xtick={2000,2005,2010,2015,2020},
        ytick={0,0.25,.5,.75,1,1.25,1.5,1.75,2, 2.25},
        ymajorgrids=true,
        grid style=dashed,
    ]
    
    \addplot[
        color=blue,
        mark=square,
        ]
        coordinates {
        (2000,1)(2001,2.043478261)(2002,0.739130435)(2003,1.130434783)(2004,0.695652174)(2005,0.913043478)(2006,0.608695652)(2007,0.782608696)(2008,0.47826087)(2009,0.47826087)(2010,0.260869565)(2011,0.608695652)(2012,0.782608696)(2013,0.217391304)(2014,0.391304348)(2015,0.52173913)(2016,0.304347826)(2017,0.130434783)(2018,0.434782609)(2019,0.130434783)(2020,0.130434783)
        };
    
    \addplot[
        color=red,
        mark=square,
        ]
        coordinates{
        (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0.043478261)(2006,0.173913043)(2007,0.086956522)(2008,0)(2009,0)(2010,0)(2011,0)(2012,0)(2013,0)(2014,0)(2015,0.086956522)(2016,0.043478261)(2017,0)(2018,0.086956522)(2019,0.043478261)(2020,0)
        };
\end{axis}
\end{tikzpicture}}
\subfloat[caption 6]{
\begin{tikzpicture}
    \begin{axis}[
        height=0.2\paperheight,
        title={Cluster 5},
        xlabel={Year},
        ylabel={},
        xmin=2000, xmax=2020,
        ymin=0, ymax=6.5,
        xtick={2000,2005,2010,2015,2020},
        ytick={0,0.25,.5,.75,1,1.25,1.5,1.75,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5},
        ymajorgrids=true,
        grid style=dashed,
    ]
    
    \addplot[
        color=blue,
        mark=square,
        ]
        coordinates {
        (2000,6)(2001,1.333333333)(2002,0.888888889)(2003,1)(2004,2.333333333)(2005,2.111111111)(2006,0.777777778)(2007,1.111111111)(2008,0.777777778)(2009,0.222222222)(2010,0.777777778)(2011,0.666666667)(2012,0.111111111)(2013,0.444444444)(2014,0.111111111)(2015,0.222222222)(2016,0.111111111)(2017,0.111111111)(2018,0.222222222)(2019,0)(2020,0.111111111)
        };
    
    \addplot[
        color=red,
        mark=square,
        ]
        coordinates{
        (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)(2011,0.111111111)(2012,0)(2013,0)(2014,0)(2015,0.222222222)(2016,0)(2017,0)(2018,0.111111111)(2019,0)(2020,0)
        };
\end{axis}
\end{tikzpicture}}\\[10pt]
\subfloat[caption 7]{
\begin{tikzpicture}
    \begin{axis}[
        height=0.2\paperheight,
        title={Cluster 6},
        xlabel={Year},
        ylabel={},
        xmin=2000, xmax=2020,
        ymin=0, ymax=2,
        xtick={2000,2005,2010,2015,2020},
        ytick={0,0.25,.5,.75,1,1.25,1.5,1.75,2},
        ymajorgrids=true,
        grid style=dashed,
    ]
    
    \addplot[
        color=blue,
        mark=square,
        ]
        coordinates {
        (2000,1.4)(2001,1.2)(2002,0.2)(2003,2.8)(2004,2)(2005,1.8)(2006,3)(2007,3.6)(2008,1.8)(2009,1)(2010,1.2)(2011,2.6)(2012,1)(2013,1.4)(2014,1)(2015,1.8)(2016,0.6)(2017,0.8)(2018,1.8)(2019,0.4)(2020,0.4)
        };
    
    \addplot[
        color=red,
        mark=square,
        ]
        coordinates{
        (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)(2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0.2)(2019,0.2)(2020,0)
        };
\end{axis}
\end{tikzpicture}}
\subfloat[caption 8]{
\begin{tikzpicture}
\begin{axis}[
        height=0.2\paperheight,
        title={Cluster 7},
        xlabel={Year},
        ylabel={},
        xmin=2000, xmax=2020,
        ymin=0, ymax=10,
        xtick={2000,2005,2010,2015,2020},
        ytick={0,1,2,3,4,5,6,7,8,9,10},
        ymajorgrids=true,
        grid style=dashed,
    ]
    
    \addplot[
        color=blue,
        mark=square,
        ]
        coordinates {
        (2000,4)(2001,4)(2002,9)(2003,5)(2004,6)(2005,4)(2006,1)(2007,0)(2008,2)(2009,0)(2010,0)(2011,1)(2012,1)(2013,0)(2014,0)(2015,1)(2016,2)(2017,0)(2018,0)(2019,0)(2020,0)
        };
    
    \addplot[
        color=red,
        mark=square,
        ]
        coordinates{
        (2000,0)(2001,5)(2002,0)(2003,0)(2004,0)(2005,5)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)(2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0)(2019,0)(2020,0)
        };
\end{axis}
\end{tikzpicture}}\\
\ref{outsidelegend}
\caption{final caption}
\end{figure}
\clearpage
\restoregeometry
\chapter{Foo}
rest content
\end{document}

在此处输入图片描述

答案2

我建议为图表定义简写,这样最后的代码就不会那么混乱,也更容易维护。

该解决方案将缩放图表以适合文本列的三分之一。

\documentclass[11pt]{report}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{subcaption}
\usepackage{graphicx}


\begin{document}        

\begin{figure}[p]

%%% no comma in years
\pgfkeys{/pgf/number format/set thousands separator={}}

%%% define shorthands for the plots
\newcommand{\plotA}{%
    \begin{tikzpicture}
        \begin{axis}[
            title={Cluster 0},
            xlabel={Year},
            ylabel={},
            xmin=2000, xmax=2020,
            ymin=0, ymax=2,
            xtick={2000,2005,2010,2015,2020},
            ytick={0,0.25,.5,.75,1,1.25,1.5,1.75,2},
            legend pos=north west,
            ymajorgrids=true,
            grid style=dashed,
        ]
        
        \addplot[
            color=blue,
            mark=square,
            ]
            coordinates {
            (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)(2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0)(2019,0)(2020,0)
            };
        
        \addplot[
            color=red,
            mark=square,
            ]
            coordinates{
            (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)(2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0)(2019,0)(2020,0)
            };
            \legend{Acquisition, Divestment, yo}
        
        \end{axis}
        
        \end{tikzpicture}%
}
\newcommand{\plotB}{%
        \begin{tikzpicture}
        \begin{axis}[
            title={Cluster 1},
            xlabel={Year},
            ylabel={},
            xmin=2000, xmax=2020,
            ymin=0, ymax=2,
            xtick={2000,2005,2010,2015,2020},
            ytick={0,0.25,.5,.75,1,1.25,1.5,1.75,2},
            legend pos=north west,
            ymajorgrids=true,
            grid style=dashed,
        ]
        
        \addplot[
            color=blue,
            mark=square,
            ]
            coordinates {
            (2000,1.604166667)(2001,0.260416667)(2002,0.104166667)(2003,0.09375)(2004,0.270833333)(2005,0.15625)(2006,0.28125)(2007,0.09375)(2008,0.104166667)(2009,0.104166667)(2010,0.072916667)(2011,0.104166667)(2012,0.052083333)(2013,0.083333333)(2014,0.041666667)(2015,0.020833333)(2016,0.0625)(2017,0.0625)(2018,0.041666667)(2019,0.104166667)(2020,0.03125)
            };
        
        \addplot[
            color=red,
            mark=square,
            ]
            coordinates{
            (2000,0)(2001,0)(2002,0.010416667)(2003,0.041666667)(2004,0)(2005,0)(2006,0.020833333)(2007,0.020833333)(2008,0)(2009,0)(2010,0.010416667)(2011,0.010416667)(2012,0.03125)(2013,0.03125)(2014,0)(2015,0.03125)(2016,0.020833333)(2017,0)(2018,0)(2019,0)(2020,0.010416667)
            };
            \legend{Acquisition, Divestment, yo}
        
        \end{axis}
        
        \end{tikzpicture}%
}
\newcommand{\plotC}{%
        \begin{tikzpicture}
        \begin{axis}[
            title={Cluster 2},
            xlabel={Year},
            ylabel={},
            xmin=2000, xmax=2020,
            ymin=0, ymax=0.2,
            xtick={2000,2005,2010,2015,2020},
            ytick={0,0.05,.1,.15,.2},
            legend pos=north west,
            ymajorgrids=true,
            grid style=dashed,
        ]
        
        \addplot[
            color=blue,
            mark=square,
            ]
            coordinates {
            (2000,0.063683305)(2001,0.076592083)(2002,0.083476764)(2003,0.070567986)(2004,0.081755594)(2005,0.092943201)(2006,0.098106713)(2007,0.139414802)(2008,0.111876076)(2009,0.089500861)(2010,0.100688468)(2011,0.096385542)(2012,0.093803787)(2013,0.081755594)(2014,0.102409639)(2015,0.06626506)(2016,0.100688468)(2017,0.090361446)(2018,0.080895009)(2019,0.06454389)(2020,0.048192771)
            };
        
        \addplot[
            color=red,
            mark=square,
            ]
            coordinates{
            (2000,0.024956971)(2001,0.022375215)(2002,0.009466437)(2003,0.012048193)(2004,0.008605852)(2005,0.030981067)(2006,0.017211704)(2007,0.016351119)(2008,0.015490534)(2009,0.014629948)(2010,0.020654045)(2011,0.01979346)(2012,0.0232358)(2013,0.010327022)(2014,0.018072289)(2015,0.020654045)(2016,0.017211704)(2017,0.014629948)(2018,0.015490534)(2019,0.016351119)(2020,0.010327022)
            };
            \legend{Acquisition, Divestment, yo}
        
        \end{axis}
        
        \end{tikzpicture}%
}
\newcommand{\plotD}{%
        \begin{tikzpicture}
        \begin{axis}[
            title={Cluster 3},
            xlabel={Year},
            ylabel={},
            xmin=2000, xmax=2020,
            ymin=0, ymax=1.5,
            xtick={2000,2005,2010,2015,2020},
            ytick={0,0.25,.5,.75,1,1.25,1.5},
            legend pos=north west,
            ymajorgrids=true,
            grid style=dashed,
        ]
        
        \addplot[
            color=blue,
            mark=square,
            ]
            coordinates {
            (2000,0)(2001,0)(2002,0)(2003,0.012658228)(2004,0.050632911)(2005,0)(2006,0.012658228)(2007,0.012658228)(2008,0.012658228)(2009,0.037974684)(2010,0.050632911)(2011,0)(2012,0.050632911)(2013,0.025316456)(2014,0.227848101)(2015,1.316455696)(2016,0.126582278)(2017,0.063291139)(2018,0.113924051)(2019,0.037974684)(2020,0.012658228)
            };
        
        \addplot[
            color=red,
            mark=square,
            ]
            coordinates{
            (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)(2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0.012658228)(2018,0)(2019,0)(2020,0)
            };
            \legend{Acquisition, Divestment, yo}
        
        \end{axis}
        
        \end{tikzpicture}%
}
\newcommand{\plotE}{%
        \begin{tikzpicture}
        \begin{axis}[
            title={Cluster 4},
            xlabel={Year},
            ylabel={},
            xmin=2000, xmax=2020,
            ymin=0, ymax=2.25,
            xtick={2000,2005,2010,2015,2020},
            ytick={0,0.25,.5,.75,1,1.25,1.5,1.75,2, 2.25},
            legend pos=north west,
            ymajorgrids=true,
            grid style=dashed,
        ]
        
        \addplot[
            color=blue,
            mark=square,
            ]
            coordinates {
            (2000,1)(2001,2.043478261)(2002,0.739130435)(2003,1.130434783)(2004,0.695652174)(2005,0.913043478)(2006,0.608695652)(2007,0.782608696)(2008,0.47826087)(2009,0.47826087)(2010,0.260869565)(2011,0.608695652)(2012,0.782608696)(2013,0.217391304)(2014,0.391304348)(2015,0.52173913)(2016,0.304347826)(2017,0.130434783)(2018,0.434782609)(2019,0.130434783)(2020,0.130434783)
            };
        
        \addplot[
            color=red,
            mark=square,
            ]
            coordinates{
            (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0.043478261)(2006,0.173913043)(2007,0.086956522)(2008,0)(2009,0)(2010,0)(2011,0)(2012,0)(2013,0)(2014,0)(2015,0.086956522)(2016,0.043478261)(2017,0)(2018,0.086956522)(2019,0.043478261)(2020,0)
            };
            \legend{Acquisition, Divestment, yo}
        
        \end{axis}
        
        \end{tikzpicture}%
}
\newcommand{\plotF}{%
        \begin{tikzpicture}
        \begin{axis}[
            title={Cluster 5},
            xlabel={Year},
            ylabel={},
            xmin=2000, xmax=2020,
            ymin=0, ymax=6.5,
            xtick={2000,2005,2010,2015,2020},
            ytick={0,0.25,.5,.75,1,1.25,1.5,1.75,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5},
            legend pos=north west,
            ymajorgrids=true,
            grid style=dashed,
        ]
        
        \addplot[
            color=blue,
            mark=square,
            ]
            coordinates {
            (2000,6)(2001,1.333333333)(2002,0.888888889)(2003,1)(2004,2.333333333)(2005,2.111111111)(2006,0.777777778)(2007,1.111111111)(2008,0.777777778)(2009,0.222222222)(2010,0.777777778)(2011,0.666666667)(2012,0.111111111)(2013,0.444444444)(2014,0.111111111)(2015,0.222222222)(2016,0.111111111)(2017,0.111111111)(2018,0.222222222)(2019,0)(2020,0.111111111)
            };
        
        \addplot[
            color=red,
            mark=square,
            ]
            coordinates{
            (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)(2011,0.111111111)(2012,0)(2013,0)(2014,0)(2015,0.222222222)(2016,0)(2017,0)(2018,0.111111111)(2019,0)(2020,0)
            };
            \legend{Acquisition, Divestment, yo}
        
        \end{axis}
        
        \end{tikzpicture}%
}
\newcommand{\plotG}{%
        \begin{tikzpicture}
        \begin{axis}[
            title={Cluster 6},
            xlabel={Year},
            ylabel={},
            xmin=2000, xmax=2020,
            ymin=0, ymax=2,
            xtick={2000,2005,2010,2015,2020},
            ytick={0,0.25,.5,.75,1,1.25,1.5,1.75,2},
            legend pos=north west,
            ymajorgrids=true,
            grid style=dashed,
        ]
        
        \addplot[
            color=blue,
            mark=square,
            ]
            coordinates {
            (2000,1.4)(2001,1.2)(2002,0.2)(2003,2.8)(2004,2)(2005,1.8)(2006,3)(2007,3.6)(2008,1.8)(2009,1)(2010,1.2)(2011,2.6)(2012,1)(2013,1.4)(2014,1)(2015,1.8)(2016,0.6)(2017,0.8)(2018,1.8)(2019,0.4)(2020,0.4)
            };
        
        \addplot[
            color=red,
            mark=square,
            ]
            coordinates{
            (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)(2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0.2)(2019,0.2)(2020,0)
            };
            \legend{Acquisition, Divestment, yo}
        
        \end{axis}
        
        \end{tikzpicture}%
}
\newcommand{\plotH}{%
        \begin{tikzpicture}
        \begin{axis}[
            title={Cluster 7},
            xlabel={Year},
            ylabel={},
            xmin=2000, xmax=2020,
            ymin=0, ymax=10,
            xtick={2000,2005,2010,2015,2020},
            ytick={0,1,2,3,4,5,6,7,8,9,10},
            legend pos=north west,
            ymajorgrids=true,
            grid style=dashed,
        ]
        
        \addplot[
            color=blue,
            mark=square,
            ]
            coordinates {
            (2000,4)(2001,4)(2002,9)(2003,5)(2004,6)(2005,4)(2006,1)(2007,0)(2008,2)(2009,0)(2010,0)(2011,1)(2012,1)(2013,0)(2014,0)(2015,1)(2016,2)(2017,0)(2018,0)(2019,0)(2020,0)
            };
        
        \addplot[
            color=red,
            mark=square,
            ]
            coordinates{
            (2000,0)(2001,5)(2002,0)(2003,0)(2004,0)(2005,5)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)(2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0)(2019,0)(2020,0)
            };
            \legend{Acquisition, Divestment, yo}
        
        \end{axis}
        \end{tikzpicture}%
}

%%% now we play with the figures
%%% first row
\begin{subfigure}{0.32\columnwidth}
  \resizebox{\textwidth}{!}{\plotA}
  \caption{Caption for plot A}
\end{subfigure}\hfill
\begin{subfigure}{0.32\columnwidth}
  \resizebox{\textwidth}{!}{\plotB}
  \caption{Caption for plot B}
\end{subfigure}\hfill
\begin{subfigure}{0.32\columnwidth}
  \resizebox{\textwidth}{!}{\plotC}
  \caption{Caption for plot C}
\end{subfigure}

\bigskip

%%% second row
\begin{subfigure}{0.32\columnwidth}
  \resizebox{\textwidth}{!}{\plotD}
  \caption{Caption for plot D}
\end{subfigure}\hfill
\begin{subfigure}{0.32\columnwidth}
  \resizebox{\textwidth}{!}{\plotE}
  \caption{Caption for plot E}
\end{subfigure}\hfill
\begin{subfigure}{0.32\columnwidth}
  \resizebox{\textwidth}{!}{\plotF}
  \caption{Caption for plot F}
\end{subfigure}

\bigskip

%%% third row
\hspace*{\fill}%
\begin{subfigure}{0.32\columnwidth}
  \resizebox{\textwidth}{!}{\plotG}
  \caption{Caption for plot G}
\end{subfigure}%
\hspace*{0.04\columnwidth}%
\begin{subfigure}{0.32\columnwidth}
  \resizebox{\textwidth}{!}{\plotH}
  \caption{Caption for plot H}
\end{subfigure}%
\hspace*{\fill}

\caption{A caption for the whole set of plots}

\end{figure}

\end{document}

在此处输入图片描述

答案3

编辑:

  • 对于每个图下方的子标题,需要将其插入subfiguresubfloats环境中,这样才能编写 sub.captions。
  • 该软件包的最新版本(v 1.3)subcaption定义了这两种环境。
  • 在下面的 MWE 中,我决定使用它,subfloat因为它的代码较短。
  • 由于子图的样式设置有很多相同之处,因此将它们分组到公共的 中是有意义的\pgfplotsset。这可以使代码更短更清晰。

在此处输入图片描述

\documentclass{article}
\usepackage[margin=20mm]{geometry}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\usepackage[aboveskip=0.5ex, belowskip=2ex]{subcaption}


\begin{document}
    \begin{figure}
    \centering
\pgfplotsset{width=0.33\linewidth, 
             height=0.4\linewidth,
    xlabel={Year},
    ylabel={},
    xmin=2000, xmax=2020,
    ymin=0,
    xtick={2000,2005,2010,2015,2020},
    yticklabel style = {font=\small, xshift=-1pt,
                        /pgf/number format/fixed zerofill},
    xticklabel style = {font=\small,
                        /pgf/number format/1000 sep=},
    legend style={legend pos=north east, anchor=north east, font=\footnotesize},
    ymajorgrids=true,
    grid style=dashed}
    
\subfloat[caption of sub figure a]{
    \begin{tikzpicture}
\begin{axis}[title={Cluster 0},
             ytick={0,.25,...,2},
             ymax=2]
%
\addplot +[mark=square] coordinates {
        (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)
        (2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0)(2019,0)(2020,0)
                    };
\addplot +[mark=square] coordinates{
        (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)
        (2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0)(2019,0)(2020,0)
                    };
        \legend{Acquisition, Divestment, yo}
    \end{axis}
    \end{tikzpicture}
}
\hfill
\subfloat[caption of sub figure b]{
    \begin{tikzpicture}
\begin{axis}[title={Cluster 1},
             ytick={0,.25,...,2},
             ymax=2]
%
\addplot +[mark=square] coordinates {
(2000,1.604166667)(2001,0.260416667)(2002,0.104166667)(2003,0.09375) (2004,0.270833333)(2005,0.15625)
        (2006,0.28125)(2007,0.09375)(2008,0.104166667)(2009,0.104166667)(2010,0.072916667)
        (2011,0.104166667)(2012,0.052083333)(2013,0.083333333)(2014,0.041666667)(2015,0.020833333)
        (2016,0.0625)(2017,0.0625)(2018,0.041666667)(2019,0.104166667)(2020,0.03125)
        };
\addplot +[mark=square] coordinates {
(2000,0)(2001,0)(2002,0.010416667)(2003,0.041666667)(2004,0)(2005,0)
        (2006,0.020833333)(2007,0.020833333)(2008,0)(2009,0)(2010,0.010416667)
        (2011,0.010416667)(2012,0.03125)(2013,0.03125)(2014,0)(2015,0.03125)
        (2016,0.020833333)(2017,0)(2018,0)(2019,0)(2020,0.010416667)
        };
        \legend{Acquisition, Divestment, yo}
\end{axis}
    \end{tikzpicture}
}
\hfill
\subfloat[caption of sub figure c]{
    \begin{tikzpicture}
\begin{axis}[title={Cluster 2},
             ytick={0,.025,...,0.2},
             ymax=0.2,   
             yticklabel style = {font=\small,
                                 /pgf/number format/.cd,fixed, fixed zerofill,
                                 precision=3},
            ]
%
\addplot +[mark=square] coordinates {
(2000,0.063683305)(2001,0.076592083)(2002,0.083476764)(2003,0.070567986)(2004,0.081755594)(2005,0.092943201)
        (2006,0.098106713)(2007,0.139414802)(2008,0.111876076)(2009,0.089500861)(2010,0.100688468)
        (2011,0.096385542)(2012,0.093803787)(2013,0.081755594)(2014,0.102409639)(2015,0.06626506)
        (2016,0.100688468)(2017,0.090361446)(2018,0.080895009)(2019,0.06454389)(2020,0.048192771)
        };
\addplot +[mark=square] coordinates {
(2000,0.024956971)(2001,0.022375215)(2002,0.009466437)(2003,0.012048193)(2004,0.008605852)(2005,0.030981067)
    (2006,0.017211704)(2007,0.016351119)(2008,0.015490534)(2009,0.014629948)(2010,0.020654045)
    (2011,0.01979346)(2012,0.0232358)(2013,0.010327022)(2014,0.018072289)(2015,0.020654045)
    (2016,0.017211704)(2017,0.014629948)(2018,0.015490534)(2019,0.016351119)(2020,0.010327022)
        };
        \legend{Acquisition, Divestment, yo}
\end{axis}
    \end{tikzpicture}
}
    
\subfloat[caption of sub figure d]{
    \begin{tikzpicture}
\begin{axis}[title={Cluster 3},
             ytick={0,.25,...,2},
             ymax=2]
%
\addplot +[mark=square] coordinates {
        (2000,0)(2001,0)(2002,0)(2003,0.012658228)(2004,0.050632911)(2005,0)
        (2006,0.012658228)(2007,0.012658228)(2008,0.012658228)(2009,0.037974684) (2010,0.050632911)
        (2011,0)(2012,0.050632911)(2013,0.025316456)(2014,0.227848101) (2015,1.316455696)
        (2016,0.126582278)(2017,0.063291139)(2018,0.113924051)(2019,0.037974684)(2020,0.012658228)
        };
\addplot +[mark=square] coordinates{
        (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)
        (2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0.012658228)(2018,0)(2019,0)(2020,0)
        };
        \legend{Acquisition, Divestment, yo}
\end{axis}
    \end{tikzpicture}
}
\hfill
\subfloat[caption of sub figure e]{
    \begin{tikzpicture}
\begin{axis}[title={Cluster 4},
             ytick={0,0.25,...,2.5},
             ymax=2.5]
%
\addplot +[mark=square] coordinates {
(2000,1)(2001,2.043478261)(2002,0.739130435)(2003,1.130434783)(2004,0.695652174)
    (2005,0.913043478)(2006,0.608695652)(2007,0.782608696)(2008,0.47826087)(2009,0.47826087)
    (2010,0.260869565)(2011,0.608695652)(2012,0.782608696)(2013,0.217391304)(2014,0.391304348)
    (2015,0.52173913)(2016,0.304347826)(2017,0.130434783)(2018,0.434782609)(2019,0.130434783)(2020,0.130434783)
                    };
\addplot +[mark=square] coordinates {
(2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0.043478261)
    (2006,0.173913043)(2007,0.086956522)(2008,0)(2009,0)(2010,0)
    (2011,0)(2012,0)(2013,0)(2014,0)(2015,0.086956522)
    (2016,0.043478261)(2017,0)(2018,0.086956522)(2019,0.043478261)(2020,0)
        };
        \legend{Acquisition, Divestment, yo}
\end{axis}
    \end{tikzpicture}
}
\hfill
\subfloat[caption of sub figure f]{
    \begin{tikzpicture}
    \begin{axis}[title={Cluster 5},
             ytick={0,1,...,7},
             ymax=7]
%
\addplot +[mark=square] coordinates {
(2000,6)(2001,1.333333333)(2002,0.888888889)(2003,1)(2004,2.333333333)(2005,2.111111111)
    (2006,0.777777778)(2007,1.111111111)(2008,0.777777778)(2009,0.222222222)(2010,0.777777778)
    (2011,0.666666667)(2012,0.111111111)(2013,0.444444444)(2014,0.111111111)(2015,0.222222222)
    (2016,0.111111111)(2017,0.111111111)(2018,0.222222222)(2019,0)(2020,0.111111111)
        };
\addplot +[mark=square] coordinates{
        (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)
        (2011,0.111111111)(2012,0)(2013,0)(2014,0)(2015,0.222222222)
        (2016,0)(2017,0)(2018,0.111111111)(2019,0)(2020,0)
        };
        \legend{Acquisition, Divestment, yo}
\end{axis}
    \end{tikzpicture}
}

\subfloat[caption of sub figure g]{
    \begin{tikzpicture}
\begin{axis}[title={Cluster 6},
             ytick={0,.5,...,4},
             ymax=4]
%
\addplot +[mark=square] coordinates {
    (2000,1.4)(2001,1.2)(2002,0.2)(2003,2.8)(2004,2)(2005,1.8)(2006,3)(2007,3.6)(2008,1.8)(2009,1)
    (2010,1.2)(2011,2.6)(2012,1)(2013,1.4)(2014,1)(2015,1.8)(2016,0.6)(2017,0.8)(2018,1.8)(2019,0.4)(2020,0.4)
        };
\addplot +[mark=square] coordinates {
        (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)
        (2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0.2)(2019,0.2)(2020,0)
        };
        \legend{Acquisition, Divestment, yo}
\end{axis}
    \end{tikzpicture}
}
\hfil
\subfloat[caption of sub figure h]{
    \begin{tikzpicture}
\begin{axis}[title={Cluster 7},
             ytick={0,2,...,10},
             ymax=10
             ]
%
\addplot +[mark=square]coordinates {
        (2000,4)(2001,4)(2002,9)(2003,5)(2004,6)(2005,4)(2006,1)(2007,0)(2008,2)(2009,0)(2010,0)
        (2011,1)(2012,1)(2013,0)(2014,0)(2015,1)(2016,2)(2017,0)(2018,0)(2019,0)(2020,0)
        };
\addplot +[mark=square]coordinates{
        (2000,0)(2001,5)(2002,0)(2003,0)(2004,0)(2005,5)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)
        (2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0)(2019,0)(2020,0)
        };
        \legend{Acquisition, Divestment, yo}
\end{axis}
    \end{tikzpicture}
}
\caption{My diagrams ...}
\label{tab:my table}
    \end{figure}
\end{document}

附录:

  • 根据我的喜好,图形的宽度不应大于文本区域的宽度。如果出于某种原因(例如图像可以更大),它应该只在其外边框上突出文本区域,如下面的 MWE 所示。
  • 您可能考虑为所有图使用一个共同的图例。例如,它可以放置在最后一个子图的右侧,参见下面的 MWE。
\documentclass{article}
\usepackage[margin=25mm]{geometry}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}% For dummy text. Don't needed in a real document
\renewcommand{\topfraction}{.95}
\renewcommand{\textfraction}{.05}

\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\usepackage[aboveskip=0.5ex, belowskip=2ex]{subcaption}
\usepackage[strict]{changepage}

\begin{document}
    \begin{figure}[htb]
\pgfplotsset{width=0.33\linewidth,
             ymajorgrids=true,
             grid style=dashed,
    xlabel={Year},
    ylabel={},
    xmin=2000, xmax=2020,
    ymin=0,
    xtick={2000,2005,2010,2015,2020},
    yticklabel style = {font=\small, xshift=-1pt,
                        /pgf/number format/fixed zerofill
                        },
    xticklabel style = {font=\small, yshift=-1pt,
                        /pgf/number format/1000 sep=},
            }
\begin{adjustwidth*}{}{-\marginparwidth}
\subfloat[caption of sub figure a   \label{subtab:mytable-a}]%
{
    \begin{tikzpicture}
\begin{axis}[title={Cluster 0},
             ytick={0,.25,...,2},
             ymax=2]
%
\addplot +[mark=square] coordinates {
        (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)
        (2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0)(2019,0)(2020,0)
                    };
\addplot +[mark=square] coordinates{
        (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)
        (2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0)(2019,0)(2020,0)
                    };
    \end{axis}
    \end{tikzpicture}
}
\hfill
\subfloat[caption of sub figure b   \label{subtab:mytable-b}]%
{
    \begin{tikzpicture}
\begin{axis}[title={Cluster 1},
             ytick={0,.25,...,2},
             ymax=2]
%
\addplot +[mark=square] coordinates {
(2000,1.604166667)(2001,0.260416667)(2002,0.104166667)(2003,0.09375) (2004,0.270833333)(2005,0.15625)
        (2006,0.28125)(2007,0.09375)(2008,0.104166667)(2009,0.104166667)(2010,0.072916667)
        (2011,0.104166667)(2012,0.052083333)(2013,0.083333333)(2014,0.041666667)(2015,0.020833333)
        (2016,0.0625)(2017,0.0625)(2018,0.041666667)(2019,0.104166667)(2020,0.03125)
        };
\addplot +[mark=square] coordinates {
(2000,0)(2001,0)(2002,0.010416667)(2003,0.041666667)(2004,0)(2005,0)
        (2006,0.020833333)(2007,0.020833333)(2008,0)(2009,0)(2010,0.010416667)
        (2011,0.010416667)(2012,0.03125)(2013,0.03125)(2014,0)(2015,0.03125)
        (2016,0.020833333)(2017,0)(2018,0)(2019,0)(2020,0.010416667)
        };
\end{axis}
    \end{tikzpicture}
}
\hfill
\subfloat[caption of sub figure c   \label{subtab:mytable-c}]%
{
    \begin{tikzpicture}
\begin{axis}[title={Cluster 2},
             ytick={0,.025,...,0.2},
             ymax=0.2,
             yticklabel style = {font=\small,
                                 /pgf/number format/.cd,fixed, fixed zerofill,
                                 precision=3},
            ]
%
\addplot +[mark=square] coordinates {
(2000,0.063683305)(2001,0.076592083)(2002,0.083476764)(2003,0.070567986)(2004,0.081755594)(2005,0.092943201)
        (2006,0.098106713)(2007,0.139414802)(2008,0.111876076)(2009,0.089500861)(2010,0.100688468)
        (2011,0.096385542)(2012,0.093803787)(2013,0.081755594)(2014,0.102409639)(2015,0.06626506)
        (2016,0.100688468)(2017,0.090361446)(2018,0.080895009)(2019,0.06454389)(2020,0.048192771)
        };
\addplot +[mark=square] coordinates {
(2000,0.024956971)(2001,0.022375215)(2002,0.009466437)(2003,0.012048193)(2004,0.008605852)(2005,0.030981067)
    (2006,0.017211704)(2007,0.016351119)(2008,0.015490534)(2009,0.014629948)(2010,0.020654045)
    (2011,0.01979346)(2012,0.0232358)(2013,0.010327022)(2014,0.018072289)(2015,0.020654045)
    (2016,0.017211704)(2017,0.014629948)(2018,0.015490534)(2019,0.016351119)(2020,0.010327022)
        };
\end{axis}
    \end{tikzpicture}
}

\subfloat[caption of sub figure d   \label{subtab:mytable-d}]%
{
    \begin{tikzpicture}
\begin{axis}[title={Cluster 3},
             ytick={0,.25,...,2},
             ymax=2]
%
\addplot +[mark=square] coordinates {
        (2000,0)(2001,0)(2002,0)(2003,0.012658228)(2004,0.050632911)(2005,0)
        (2006,0.012658228)(2007,0.012658228)(2008,0.012658228)(2009,0.037974684) (2010,0.050632911)
        (2011,0)(2012,0.050632911)(2013,0.025316456)(2014,0.227848101) (2015,1.316455696)
        (2016,0.126582278)(2017,0.063291139)(2018,0.113924051)(2019,0.037974684)(2020,0.012658228)
        };
\addplot +[mark=square] coordinates{
        (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)
        (2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0.012658228)(2018,0)(2019,0)(2020,0)
        };
\end{axis}
    \end{tikzpicture}
}
\hfill
\subfloat[caption of sub figure e   \label{subtab:mytable-e}]%
{
    \begin{tikzpicture}
\begin{axis}[title={Cluster 4},
             ytick={0,0.25,...,2.5},
             ymax=2.5]
%
\addplot +[mark=square] coordinates {
(2000,1)(2001,2.043478261)(2002,0.739130435)(2003,1.130434783)(2004,0.695652174)
    (2005,0.913043478)(2006,0.608695652)(2007,0.782608696)(2008,0.47826087)(2009,0.47826087)
    (2010,0.260869565)(2011,0.608695652)(2012,0.782608696)(2013,0.217391304)(2014,0.391304348)
    (2015,0.52173913)(2016,0.304347826)(2017,0.130434783)(2018,0.434782609)(2019,0.130434783)(2020,0.130434783)
                    };
\addplot +[mark=square] coordinates {
(2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0.043478261)
    (2006,0.173913043)(2007,0.086956522)(2008,0)(2009,0)(2010,0)
    (2011,0)(2012,0)(2013,0)(2014,0)(2015,0.086956522)
    (2016,0.043478261)(2017,0)(2018,0.086956522)(2019,0.043478261)(2020,0)
        };
\end{axis}
    \end{tikzpicture}
}
\hfill
\subfloat[caption of sub figure f   \label{subtab:mytable-f}]%
{
    \begin{tikzpicture}
    \begin{axis}[title={Cluster 5},
             ytick={0,1,...,7},
             /pgf/number format/precision=0,
             ymax=7]
%
\addplot +[mark=square] coordinates {
(2000,6)(2001,1.333333333)(2002,0.888888889)(2003,1)(2004,2.333333333)(2005,2.111111111)
    (2006,0.777777778)(2007,1.111111111)(2008,0.777777778)(2009,0.222222222)(2010,0.777777778)
    (2011,0.666666667)(2012,0.111111111)(2013,0.444444444)(2014,0.111111111)(2015,0.222222222)
    (2016,0.111111111)(2017,0.111111111)(2018,0.222222222)(2019,0)(2020,0.111111111)
        };
\addplot +[mark=square] coordinates{
        (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)
        (2011,0.111111111)(2012,0)(2013,0)(2014,0)(2015,0.222222222)
        (2016,0)(2017,0)(2018,0.111111111)(2019,0)(2020,0)
        };
\end{axis}
    \end{tikzpicture}
}

\subfloat[caption of sub figure g   \label{subtab:mytable-g}]%
{
    \begin{tikzpicture}
\begin{axis}[title={Cluster 6},
             ytick={0,.5,...,4},
             ymax=4]
%
\addplot +[mark=square] coordinates {
    (2000,1.4)(2001,1.2)(2002,0.2)(2003,2.8)(2004,2)(2005,1.8)(2006,3)(2007,3.6)(2008,1.8)(2009,1)
    (2010,1.2)(2011,2.6)(2012,1)(2013,1.4)(2014,1)(2015,1.8)(2016,0.6)(2017,0.8)(2018,1.8)(2019,0.4)(2020,0.4)
        };
\addplot +[mark=square] coordinates {
        (2000,0)(2001,0)(2002,0)(2003,0)(2004,0)(2005,0)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)
        (2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0.2)(2019,0.2)(2020,0)
        };
\end{axis}
    \end{tikzpicture}
}
\quad
\subfloat[caption of sub figure h   \label{subtab:mytable-h}]%
{
    \begin{tikzpicture}[trim right=(current axis.south east)]
\begin{axis}[title = {Cluster 7},
             ymax=10,
             /pgf/number format/precision=0,
    legend entries = {Acquisition, Divestment, yo},
      legend style = {at={(1.6,.5)}, anchor=west,
                      font=\footnotesize}
             ]
%
\addplot +[mark=square]coordinates {
        (2000,4)(2001,4)(2002,9)(2003,5)(2004,6)(2005,4)(2006,1)(2007,0)(2008,2)(2009,0)(2010,0)
        (2011,1)(2012,1)(2013,0)(2014,0)(2015,1)(2016,2)(2017,0)(2018,0)(2019,0)(2020,0)
        };
\addplot +[mark=square]coordinates{
        (2000,0)(2001,5)(2002,0)(2003,0)(2004,0)(2005,5)(2006,0)(2007,0)(2008,0)(2009,0)(2010,0)
        (2011,0)(2012,0)(2013,0)(2014,0)(2015,0)(2016,0)(2017,0)(2018,0)(2019,0)(2020,0)
        };
\end{axis}
    \end{tikzpicture}
}

\caption{My diagrams collected in table}
\label{tab:mytable}
\end{adjustwidth*}
    \end{figure}

Now works referencing of subfigures too, for example see subfigures \ref{subtab:mytable-a} and  \ref{subtab:mytable-b} in figure \ref{tab:mytable}

\lipsum[66]
\end{document}

\lipsum[66]
\end{document}

在此处输入图片描述

(红线表示页面布局)

相关内容