我如何对齐此图像并在其正下方添加水平对齐的文本框?

我如何对齐此图像并在其正下方添加水平对齐的文本框?

我知道我之前的问题也类似。我正在写论文,还有更多这种风格的图片:对齐的图片,下方是描述其内容的文本框。我可以制作图表,但我无法将图表与文本框正确对齐。一旦我知道如何操作,我就可以在附录中添加几页。因此,如果有人能给我举个例子,我将不胜感激。谢谢!

我有这个代码:

\documentclass{article}
\usepackage[margin=0.5in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{pgfplots}

\begin{document}
\pgfplotsset{width=10cm,compat=1.9}
\pgfplotsset{domain=-1:1} 
\begin{tikzpicture}[baseline]
\begin{axis}[
    title={Men},
    xlabel={age (years)},
    ylabel={rates per 100 000},
    xticklabels={[5-9],,[15-19],,[25-29],,[35-39],,[45-49],,[55-59],,[65-69],,[75-79],,[85+]},
    xmin=0,xmax=180,
    ymin=0, ymax=700,
    xtick={10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170},
    x tick label style={rotate=60, anchor=east},
    ytick={0,50,100,150,200,250,300,350,400,450,500,550,600,650,700},
    legend pos=north west,
    ymajorgrids=true,
    grid style=dashed,
]
\addplot[
    color=blue,
    mark=square,
    ]    
    coordinates {
    (0,0)(10,0)(20,0)(30,0)(40,0)(50,0)(60,0)(70,0.4)(80,5.8)(90,28.9)(100,98.1)(110,236.4)(120,414.1)(130,631.3)(140,660.1)(150,644.2)(160,572.1)(170,621.6)
    };
\addplot[
    color=red,
    mark=square,
    ]
    coordinates {
    (0,0.5)(10,0.5)(20,0)(30,0)(40,0.4)(50,0)(60,1.3)(70,2.2)(80,6.2)(90,18.6)(100,45.8)(110,92.7)(120,166.0)(130,290.3)(140,411.2)(150,491.1)(160,529.3)(170,474.4)
    };
\addplot[
    color=brown,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0.9)(40,0.8)(50,2.1)(60,5.7)(70,7.4)(80,17)(90,13.9)(100,53.8)(110,98)(120,151.3)(130,243.8)(140,318.6)(150,398.7)(160,461.6)(170,456.7)
    };    

\addplot[
    color=black,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0.4)(40,0.8)(50,0.8)(60,3.1)(70,4.8)(80,9.9)(90,13.9)(100,29.9)(110,52.7)(120,87.9)(130,146.5)(140,199.4)(150,267.4)(160,329.7)(170,327.3)
    }; 

\addplot[
    color=green,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0.4)(40,0.4)(50,0.8)(60,0.9)(70,1.8)(80,4.6)(90,9.6)(100,17)(110,35.6)(120,70.6)(130,105.7)(140,164.1)(150,218.8)(160,272.7)(170,314.6)
    };
    \legend{Prostate, Lungs/bronchus, Colon/rectum, Colon, Urinary bladder}
    \end{axis}
\end{tikzpicture}%
\hspace{0.10cm}
\begin{tikzpicture}[baseline]
\begin{axis}[
    title={Women},
    xlabel={age (years)},
    ylabel={rates per 100 000},
    xticklabels={[5-9],,[15-19],,[25-29],,[35-39],,[45-49],,[55-59],,[65-69],,[75-79],,[85+]},
    xmin=0,xmax=180,
    ymin=0, ymax=400,
    xtick={10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170},
    x tick label style={rotate=60, anchor=east},
    ytick={0,50,100,150,200,250,300,350,400,450,500,550,600,650,700},
    legend pos=north west,
    ymajorgrids=true,
    grid style=dashed,
]
\addplot[
    color=blue,
    mark=square,
    ]    
    coordinates {
    (0,0)(10,0)(20,0)(30,0.4)(40,2.2)(50,9)(60,25.3)(70,52.2)(80,104.9)(90,165.8)(100,207.7)(110,247.4)(120,303.8)(130,365.6)(140,366.5)(150,358.5)(160,318.9)(170,326.5)
    };
\addplot[
    color=red,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0)(40,0.4)(50,0.4)(60,0.4)(70,2.6)(80,8.4)(90,23.9)(100,55.5)(110,91.4)(120,147)(130,219.2)(140,284.4)(150,335.6)(160,293)(170,214.9)
    };    
\addplot[
    color=brown,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0.5)(40,0.4)(50,2.1)(60,3.5)(70,7.9)(80,14.6)(90,24.6)(100,49.1)(110,67)(120,102.6)(130,147)(140,204)(150,270.9)(160,330.1)(170,355)
    };    
\addplot[
    color=black,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0.5)(40,0.4)(50,0.9)(60,2.2)(70,4.4)(80,8.8)(90,14.8)(100,29.7)(110,40.9)(120,70.2)(130,107.3)(140,154)(150,202.2)(160,252.2)(170,287.3)
    }; 
\addplot[
    color=green,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0)(40,0)(50,0.9)(60,2.6)(70,7.9)(80,9.6)(90,23.9)(100,46)(110,70.1)(120,97.6)(130,94.7)(140,89.7)(150,74.7)(160,65.5)(170,46.3)
    };
\legend{Breast, Lungs/bronchus, Colon/rectum, Colon, Corpus uteri}
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

您可以将文本放在\parbox与绘图相同宽度的范围内,或者subfiguresubcaption包中使用...

\documentclass{article}
\usepackage[margin=0.5in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{pgfplots}
\usepackage{subcaption}
\usepackage{lipsum}

\begin{document}
\pgfplotsset{width=\linewidth,compat=1.9,domain=-1:1}
\begin{figure}
\centering
\begin{subfigure}{0.45\linewidth}
\centering
\begin{tikzpicture}[baseline]
\begin{axis}[
    title={Men},
    xlabel={age (years)},
    ylabel={rates per 100 000},
    xticklabels={[5-9],,[15-19],,[25-29],,[35-39],,[45-49],,[55-59],,[65-69],,[75-79],,[85+]},
    xmin=0,xmax=180,
    ymin=0, ymax=700,
    xtick={10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170},
    x tick label style={rotate=60, anchor=east},
    ytick={0,50,100,150,200,250,300,350,400,450,500,550,600,650,700},
    legend pos=north west,
    ymajorgrids=true,
    grid style=dashed,
]
\addplot[
    color=blue,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0)(40,0)(50,0)(60,0)(70,0.4)(80,5.8)(90,28.9)(100,98.1)(110,236.4)(120,414.1)(130,631.3)(140,660.1)(150,644.2)(160,572.1)(170,621.6)
    };
\addplot[
    color=red,
    mark=square,
    ]
    coordinates {
    (0,0.5)(10,0.5)(20,0)(30,0)(40,0.4)(50,0)(60,1.3)(70,2.2)(80,6.2)(90,18.6)(100,45.8)(110,92.7)(120,166.0)(130,290.3)(140,411.2)(150,491.1)(160,529.3)(170,474.4)
    };
\addplot[
    color=brown,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0.9)(40,0.8)(50,2.1)(60,5.7)(70,7.4)(80,17)(90,13.9)(100,53.8)(110,98)(120,151.3)(130,243.8)(140,318.6)(150,398.7)(160,461.6)(170,456.7)
    };

\addplot[
    color=black,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0.4)(40,0.8)(50,0.8)(60,3.1)(70,4.8)(80,9.9)(90,13.9)(100,29.9)(110,52.7)(120,87.9)(130,146.5)(140,199.4)(150,267.4)(160,329.7)(170,327.3)
    };

\addplot[
    color=green,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0.4)(40,0.4)(50,0.8)(60,0.9)(70,1.8)(80,4.6)(90,9.6)(100,17)(110,35.6)(120,70.6)(130,105.7)(140,164.1)(150,218.8)(160,272.7)(170,314.6)
    };
    \legend{Prostate, Lungs/bronchus, Colon/rectum, Colon, Urinary bladder}
    \end{axis}
\end{tikzpicture}%
\caption{\lipsum*[1]}
\end{subfigure}%
\hfill
\begin{subfigure}{0.45\linewidth}
\centering
\begin{tikzpicture}[baseline]
\begin{axis}[
    title={Women},
    xlabel={age (years)},
    ylabel={rates per 100 000},
    xticklabels={[5-9],,[15-19],,[25-29],,[35-39],,[45-49],,[55-59],,[65-69],,[75-79],,[85+]},
    xmin=0,xmax=180,
    ymin=0, ymax=400,
    xtick={10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170},
    x tick label style={rotate=60, anchor=east},
    ytick={0,50,100,150,200,250,300,350,400,450,500,550,600,650,700},
    legend pos=north west,
    ymajorgrids=true,
    grid style=dashed,
]
\addplot[
    color=blue,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0.4)(40,2.2)(50,9)(60,25.3)(70,52.2)(80,104.9)(90,165.8)(100,207.7)(110,247.4)(120,303.8)(130,365.6)(140,366.5)(150,358.5)(160,318.9)(170,326.5)
    };
\addplot[
    color=red,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0)(40,0.4)(50,0.4)(60,0.4)(70,2.6)(80,8.4)(90,23.9)(100,55.5)(110,91.4)(120,147)(130,219.2)(140,284.4)(150,335.6)(160,293)(170,214.9)
    };
\addplot[
    color=brown,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0.5)(40,0.4)(50,2.1)(60,3.5)(70,7.9)(80,14.6)(90,24.6)(100,49.1)(110,67)(120,102.6)(130,147)(140,204)(150,270.9)(160,330.1)(170,355)
    };
\addplot[
    color=black,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0.5)(40,0.4)(50,0.9)(60,2.2)(70,4.4)(80,8.8)(90,14.8)(100,29.7)(110,40.9)(120,70.2)(130,107.3)(140,154)(150,202.2)(160,252.2)(170,287.3)
    };
\addplot[
    color=green,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0)(40,0)(50,0.9)(60,2.6)(70,7.9)(80,9.6)(90,23.9)(100,46)(110,70.1)(120,97.6)(130,94.7)(140,89.7)(150,74.7)(160,65.5)(170,46.3)
    };
\legend{Breast, Lungs/bronchus, Colon/rectum, Colon, Corpus uteri}
\end{axis}
\end{tikzpicture}
\caption{\lipsum*[1]}
\end{subfigure}%
\end{figure}
\end{document}

在此处输入图片描述

答案2

附带floatrow包装:

\documentclass{article}
\usepackage[margin=0.5in, showframe]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{pgfplots}
\usepackage{floatrow}
\begin{document}

\begin{figure}[!ht]
\floatsetup{floatrowsep=qquad}
\begin{floatrow}
\pgfplotsset{width=9cm,compat=1.9}
\pgfplotsset{domain=-1:1}
\ffigbox[\FBwidth]{\caption{A first figure}\label{fig:1st}}{%
\begin{tikzpicture}[baseline]
\begin{axis}[
    title={Men},
    xlabel={age (years)},
    ylabel={rates per 100 000},
    xticklabels={[5-9],,[15-19],,[25-29],,[35-39],,[45-49],,[55-59],,[65-69],,[75-79],,[85+]},
    xmin=0,xmax=180,
    ymin=0, ymax=700,
    xtick={10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170},
    x tick label style={rotate=60, anchor=east},
    ytick={0,50,100,150,200,250,300,350,400,450,500,550,600,650,700},
    legend pos=north west,
    ymajorgrids=true,
    grid style=dashed,
]
\addplot[
    color=blue,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0)(40,0)(50,0)(60,0)(70,0.4)(80,5.8)(90,28.9)(100,98.1)(110,236.4)(120,414.1)(130,631.3)(140,660.1)(150,644.2)(160,572.1)(170,621.6)
    };
\addplot[
    color=red,
    mark=square,
    ]
    coordinates {
    (0,0.5)(10,0.5)(20,0)(30,0)(40,0.4)(50,0)(60,1.3)(70,2.2)(80,6.2)(90,18.6)(100,45.8)(110,92.7)(120,166.0)(130,290.3)(140,411.2)(150,491.1)(160,529.3)(170,474.4)
    };
\addplot[
    color=brown,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0.9)(40,0.8)(50,2.1)(60,5.7)(70,7.4)(80,17)(90,13.9)(100,53.8)(110,98)(120,151.3)(130,243.8)(140,318.6)(150,398.7)(160,461.6)(170,456.7)
    };

\addplot[
    color=black,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0.4)(40,0.8)(50,0.8)(60,3.1)(70,4.8)(80,9.9)(90,13.9)(100,29.9)(110,52.7)(120,87.9)(130,146.5)(140,199.4)(150,267.4)(160,329.7)(170,327.3)
    };

\addplot[
    color=green,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0.4)(40,0.4)(50,0.8)(60,0.9)(70,1.8)(80,4.6)(90,9.6)(100,17)(110,35.6)(120,70.6)(130,105.7)(140,164.1)(150,218.8)(160,272.7)(170,314.6)
    };
    \legend{Prostate, Lungs/bronchus, Colon/rectum, Colon, Urinary bladder}
    \end{axis}
\end{tikzpicture}%
}
\hfill%hspace{0.10cm}
\ffigbox[\FBwidth]{\caption{A second figure}\label{fig: 2nd}}{%
\begin{tikzpicture}[baseline]
\begin{axis}[
    title={Women},
    xlabel={age (years)},
    ylabel={rates per 100 000},
    xticklabels={[5-9],,[15-19],,[25-29],,[35-39],,[45-49],,[55-59],,[65-69],,[75-79],,[85+]},
    xmin=0,xmax=180,
    ymin=0, ymax=400,
    xtick={10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170},
    x tick label style={rotate=60, anchor=east},
    ytick={0,50,100,150,200,250,300,350,400,450,500,550,600,650,700},
    legend pos=north west,
    ymajorgrids=true,
    grid style=dashed,
]
\addplot[
    color=blue,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0.4)(40,2.2)(50,9)(60,25.3)(70,52.2)(80,104.9)(90,165.8)(100,207.7)(110,247.4)(120,303.8)(130,365.6)(140,366.5)(150,358.5)(160,318.9)(170,326.5)
    };
\addplot[
    color=red,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0)(40,0.4)(50,0.4)(60,0.4)(70,2.6)(80,8.4)(90,23.9)(100,55.5)(110,91.4)(120,147)(130,219.2)(140,284.4)(150,335.6)(160,293)(170,214.9)
    };
\addplot[
    color=brown,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0.5)(40,0.4)(50,2.1)(60,3.5)(70,7.9)(80,14.6)(90,24.6)(100,49.1)(110,67)(120,102.6)(130,147)(140,204)(150,270.9)(160,330.1)(170,355)
    };
\addplot[
    color=black,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0.5)(40,0.4)(50,0.9)(60,2.2)(70,4.4)(80,8.8)(90,14.8)(100,29.7)(110,40.9)(120,70.2)(130,107.3)(140,154)(150,202.2)(160,252.2)(170,287.3)
    };
\addplot[
    color=green,
    mark=square,
    ]
    coordinates {
    (0,0)(10,0)(20,0)(30,0)(40,0)(50,0.9)(60,2.6)(70,7.9)(80,9.6)(90,23.9)(100,46)(110,70.1)(120,97.6)(130,94.7)(140,89.7)(150,74.7)(160,65.5)(170,46.3)
    };
\legend{Breast, Lungs/bronchus, Colon/rectum, Colon, Corpus uteri}
\end{axis}
\end{tikzpicture}}
\end{floatrow}
\end{figure}

\end{document} 

在此处输入图片描述

相关内容