最后编辑

最后编辑

在此处输入图片描述编辑与您相同但没有帮助------

      \documentclass{article}
    \usepackage{pgfplots,tikz}
    \usepackage{caption}
      \DeclareCaptionLabelSeparator{fullstop}{.\quad}
      \captionsetup[figure]{labelsep=fullstop}
    \pgfplotsset{width=120mm}
    \usepackage{subcation}
         \begin{subfigure}{0.5\textwidth}
          \begin{tikzpicture}
        \begin{axis}[
          color=black,
          scale only axis,
          xmin=0,
          xmax=24,
          %xtick={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24},
          xtick={0,4,8,12,24}, %%%<------------- here
          xlabel=\ {Time},
          ymin=0,
          ymax=10,
          ytick={0,1,2,3,4,5,6,7,8,9,10},
          yticklabels={0,1,2,3,4,5,6,7,8,9,10},
          ylabel=\ {log(Cfu/cm$^{2}$)},
          y axis line style={black},
          ytick style={black},
          yticklabel style={black},
          axis x line*=bottom,
          axis y line*=left,
          tick align = outside,
          every axis legend/.append style={
            at = {(.5,-.2)},
            anchor = north,
    %       legend columns=-1, % to display legends in one line but do you really want this?
            legend cell align = left,
            draw = none,
            legend columns = 2,
          },
        ]
          \addplot [
            color=black,
            solid,
            line width=0.5pt,
            mark size=2.5pt,
            mark size=2.5pt,
            mark=square*,
            mark options={solid,fill=white}
          ]
          table[row sep=crcr]{
            0 5\\
            4 5\\
            8 9.8\\
            12 8.8\\
            24 8.62\\};
\legend {$Staphylococcus\ aureus$}
        \end{axis}
      \end{tikzpicture}
       \end{subfigure}
        \caption{Growth of different types foodborne pathogens $Staphylococcus\ aureus$.}
          \begin{subfigure}
          \begin{tikzpicture}
        \begin{axis}[
            color=black,
          scale only axis,
          xmin=0,
          xmax=24,
          %xtick={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24},
          xtick={0,4,8,12,24}, %%%<------------- here
          xlabel=\ {Time},
          ymin=0,
          ymax=10,
          ytick={0,1,2,3,4,5,6,7,8,9,10},
          yticklabels={0,1,2,3,4,5,6,7,8,9,10},
          ylabel=\ {log(Cfu/cm$^{2}$)},
          y axis line style={black},
          ytick style={black},
          yticklabel style={black},
          axis x line*=bottom,
          axis y line*=left,
          tick align = outside,
          every axis legend/.append style={
            at = {(.5,-.2)},
            anchor = north,
    %       legend columns=-1, % to display legends in one line but do you really want this?
            legend cell align = left,
            draw = none,
            legend columns = 2,
          },
        ]
          \addplot [
            color=black,
            solid,
            line width=0.5pt,
            mark size=2.5pt,
            mark size=2.5pt,
            mark=square*,
            mark options={solid,fill=white}
]
          table[row sep=crcr]{
            0 2\\
            4 3\\
            8 4.8\\
            12 7.8\\
            24 8.162\\};
            24 8.62\\};
\legend {$Escherichia\ coli$}
        \end{axis}
      \end{tikzpicture}
       \end{subfigure}
       \caption{Growth of different types foodborne pathogens $Escherichia\ coli$.}
          \begin{subfigure}{0.5\textwidth}
          \begin{tikzpicture}
        \begin{axis}[
           color=black,
          scale only axis,
          xmin=0,
          xmax=24,
          %xtick={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24},
          xtick={0,4,8,12,24}, %%%<------------- here
          xlabel=\ {Time},
          ymin=0,
          ymax=10,
          ytick={0,1,2,3,4,5,6,7,8,9,10},
          yticklabels={0,1,2,3,4,5,6,7,8,9,10},
          ylabel=\ {log(Cfu/cm$^{2}$)},
          y axis line style={black},
          ytick style={black},
          yticklabel style={black},
          axis x line*=bottom,
          axis y line*=left,
          tick align = outside,
          every axis legend/.append style={
            at = {(.5,-.2)},
            anchor = north,
    %       legend columns=-1, % to display legends in one line but do you really want this?
            legend cell align = left,
            draw = none,
            legend columns = 2,
          },
        ]
          \addplot [
            color=black,
            solid,
            line width=0.5pt,
            mark size=2.5pt,
            mark size=2.5pt,
            mark=square*,
            mark options={solid,fill=white}
           ]
          table[row sep=crcr]{
            0 3\\
            4 1\\
            8 2.8\\
            12 2.8\\
            24 2.162\\};
            24 8.62\\};
\legend {$Listeria\ monocytogenes$}
        \end{axis}
      \end{tikzpicture}
       \end{subfigure}
       \caption{Growth of different types foodborne pathogens $Listeria\ monocytogenes$.}
          \begin{subfigure}{0.5\textwidth}
          \begin{tikzpicture}
        \begin{axis}[
            color=black,
          scale only axis,
          xmin=0,
          xmax=24,
          %xtick={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24},
          xtick={0,4,8,12,24}, %%%<------------- here
          xlabel=\ {Time},
          ymin=0,
          ymax=10,
          ytick={0,1,2,3,4,5,6,7,8,9,10},
          yticklabels={0,1,2,3,4,5,6,7,8,9,10},
          ylabel=\ {log(Cfu/cm$^{2}$)},
          y axis line style={black},
          ytick style={black},
          yticklabel style={black},
          axis x line*=bottom,
          axis y line*=left,
          tick align = outside,
          every axis legend/.append style={
            at = {(.5,-.2)},
            anchor = north,
    %       legend columns=-1, % to display legends in one line but do you really want this?
            legend cell align = left,
            draw = none,
            legend columns = 2,
          },
        ]
          \addplot [
            color=black,
            solid,
            line width=0.5pt,
            mark size=2.5pt,
            mark size=2.5pt,
            mark=square*,
            mark options={solid,fill=white}
           ]
          table[row sep=crcr]{
            0 3\\
            4 1\\
            8 2.8\\
            12 2.8\\
            24 2.162\\};
            24 8.62\\};
\legend {$Listeria\ monocytogenes$}
        \end{axis}
      \end{tikzpicture}
       \end{subfigure}
          \begin{subfigure}{0.5\textwidth}
          \begin{tikzpicture}
        \begin{axis}[
            color=black,
          scale only axis,
          xmin=0,
          xmax=24,
          %xtick={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24},
          xtick={0,4,8,12,24}, %%%<------------- here
          xlabel=\ {Time},
          ymin=0,
          ymax=10,
          ytick={0,1,2,3,4,5,6,7,8,9,10},
          yticklabels={0,1,2,3,4,5,6,7,8,9,10},
          ylabel=\ {log(Cfu/cm$^{2}$)},
          y axis line style={black},
          ytick style={black},
          yticklabel style={black},
          axis x line*=bottom,
          axis y line*=left,
          tick align = outside,
          every axis legend/.append style={
            at = {(.5,-.2)},
            anchor = north,
    %       legend columns=-1, % to display legends in one line but do you really want this?
            legend cell align = left,
            draw = none,
            legend columns = 2,
          },
        ]
          \addplot [
            color=black,
            solid,
            line width=0.5pt,
            mark size=2.5pt,
            mark size=2.5pt,
            mark=square*,
            mark options={solid,fill=white}
          ]
          table[row sep=crcr]{
            0 5\\
            4 5\\
            8 9.8\\
            12 8.8\\
            24 8.62\\};
          \addplot [
            color=black,
            solid,
            line width=0.5pt,
            mark size=2.5pt,
            mark size=2.5pt,
            mark=*,
            mark options={solid,fill=white}]
          table[row sep=crcr]{
            0 2\\
            4 3\\
            8 4.8\\
            12 7.8\\
            24 8.162\\};
          \addplot [
            color=black,
            solid,
            line width=0.5pt,
            mark size=2.5pt,
            mark size=2.5pt,
            mark=halfdiamond*,
            mark options={solid,fill=white}]
          table[row sep=crcr]{
            0 3\\
            4 1\\
            8 2.8\\
            12 2.8\\
            24 2.162\\};
          \addplot [
            color=black,
            solid,
            line width=0.5pt,
            mark size=2.5pt,
            mark size=2.5pt,
            mark=triangle*,
            mark options={solid,fill=white}]
          table[row sep=crcr]{
            0 4\\
            4 3.3\\
            8 5.8\\
            12 5.7\\
            24 6.162\\};
\legend {$Campylobacter\ jejuni$,C.J1,C.J2,C.J.2}
        \end{axis}
      \end{tikzpicture}
       \end{subfigure}
      \caption{Growth of different types foodborne pathogens $Campylobacter\ jejuni$.}
    \end{figure}
    \end{document}

答案1

使用盒子。

\documentclass{article}
    \usepackage{pgfplots,tikz}
    \usepackage{caption}
      \DeclareCaptionLabelSeparator{fullstop}{.\quad}
      \captionsetup[figure]{labelsep=fullstop}
    \pgfplotsset{width=120mm}
    \newbox{\mybox}
    \savebox{\mybox}{%
          \begin{tikzpicture}
        \begin{axis}[
          color=black,
          scale only axis,
          xmin=0,
          xmax=24,
          %xtick={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24},
          xtick={0,4,8,12,24}, %%%<------------- here
          xlabel=\ {Time},
          ymin=0,
          ymax=10,
          ytick={0,1,2,3,4,5,6,7,8,9,10},
          yticklabels={0,1,2,3,4,5,6,7,8,9,10},
          ylabel=\ {log(Cfu/cm$^{2}$)},
          y axis line style={black},
          ytick style={black},
          yticklabel style={black},
          axis x line*=bottom,
          axis y line*=left,
          tick align = outside,
          every axis legend/.append style={
            at = {(.5,-.2)},
            anchor = north,
    %       legend columns=-1, % to display legends in one line but do you really want this?
            legend cell align = left,
            draw = none,
            legend columns = 2,
          },
        ]
          \addplot [
            color=black,
            solid,
            line width=0.5pt,
            mark size=2.5pt,
            mark size=2.5pt,
            mark=square*,
            mark options={solid,fill=white}
          ]
          table[row sep=crcr]{
            0 5\\
            4 5\\
            8 9.8\\
            12 8.8\\
            24 8.62\\};
          \addplot [
            color=black,
            solid,
            line width=0.5pt,
            mark size=2.5pt,
            mark size=2.5pt,
            mark=*,
            mark options={solid,fill=white}]
          table[row sep=crcr]{
            0 2\\
            4 3\\
            8 4.8\\
            12 7.8\\
            24 8.162\\};
          \addplot [
            color=black,
            solid,
            line width=0.5pt,
            mark size=2.5pt,
            mark size=2.5pt,
            mark=halfdiamond*,
            mark options={solid,fill=white}]
          table[row sep=crcr]{
            0 3\\
            4 1\\
            8 2.8\\
            12 2.8\\
            24 2.162\\};
          \addplot [
            color=black,
            solid,
            line width=0.5pt,
            mark size=2.5pt,
            mark size=2.5pt,
            mark=triangle*,
            mark options={solid,fill=white}]
          table[row sep=crcr]{
            0 4\\
            4 3.3\\
            8 5.8\\
            12 5.7\\
            24 6.162\\};
          \legend {$Staphylococcus\ aureus$, $Escherichia\ coli$,$Listeria\ monocytogenes$,$Campylobacter\ jejuni$}
        \end{axis}
      \end{tikzpicture}
      }
    \begin{document}

    \begin{figure}
      \resizebox{0.5\linewidth}{!}{\usebox{\mybox}}
      \resizebox{0.5\linewidth}{!}{\usebox{\mybox}}
      \resizebox{0.5\linewidth}{!}{\usebox{\mybox}}
      \resizebox{0.5\linewidth}{!}{\usebox{\mybox}}
      \caption{Growth of different types foodborne pathogens.}
    \end{figure}

    \end{document}

在此处输入图片描述

  1. 相反,您可以通过将选项传递给轴来\resizebox调整图的宽度width=0.5\linewidth
  2. 如果您想要每个图的单独标题,请使用subfigure来自subcaption包或subfloat来自subfig包。

最后编辑

\documentclass{article}
    \usepackage{pgfplots,tikz}
    \usepackage{caption,subcaption}
      \DeclareCaptionLabelSeparator{fullstop}{.\quad}
      \captionsetup[figure]{labelsep=fullstop}
    \pgfplotsset{width=120mm}
    \newbox{\mybox}
    \savebox{\mybox}{%
          \begin{tikzpicture}
        \begin{axis}[
          color=black,
          scale only axis,
          xmin=0,
          xmax=24,
          %xtick={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24},
          xtick={0,4,8,12,24}, %%%<------------- here
          xlabel=\ {Time},
          ymin=0,
          ymax=10,
          ytick={0,1,2,3,4,5,6,7,8,9,10},
          yticklabels={0,1,2,3,4,5,6,7,8,9,10},
          ylabel=\ {log(Cfu/cm$^{2}$)},
          y axis line style={black},
          ytick style={black},
          yticklabel style={black},
          axis x line*=bottom,
          axis y line*=left,
          tick align = outside,
          every axis legend/.append style={
            at = {(.5,-.2)},
            anchor = north,
    %       legend columns=-1, % to display legends in one line but do you really want this?
            legend cell align = left,
            draw = none,
            legend columns = 2,
          },
        ]
          \addplot [
            color=black,
            solid,
            line width=0.5pt,
            mark size=2.5pt,
            mark size=2.5pt,
            mark=square*,
            mark options={solid,fill=white}
          ]
          table[row sep=crcr]{
            0 5\\
            4 5\\
            8 9.8\\
            12 8.8\\
            24 8.62\\};
          \addplot [
            color=black,
            solid,
            line width=0.5pt,
            mark size=2.5pt,
            mark size=2.5pt,
            mark=*,
            mark options={solid,fill=white}]
          table[row sep=crcr]{
            0 2\\
            4 3\\
            8 4.8\\
            12 7.8\\
            24 8.162\\};
          \addplot [
            color=black,
            solid,
            line width=0.5pt,
            mark size=2.5pt,
            mark size=2.5pt,
            mark=halfdiamond*,
            mark options={solid,fill=white}]
          table[row sep=crcr]{
            0 3\\
            4 1\\
            8 2.8\\
            12 2.8\\
            24 2.162\\};
          \addplot [
            color=black,
            solid,
            line width=0.5pt,
            mark size=2.5pt,
            mark size=2.5pt,
            mark=triangle*,
            mark options={solid,fill=white}]
          table[row sep=crcr]{
            0 4\\
            4 3.3\\
            8 5.8\\
            12 5.7\\
            24 6.162\\};
          \legend {$Staphylococcus\ aureus$, $Escherichia\ coli$,$Listeria\ monocytogenes$,$Campylobacter\ jejuni$}
        \end{axis}
      \end{tikzpicture}
      }
    \begin{document}

    \begin{figure}
     \begin{subfigure}{0.5\textwidth}
      \resizebox{\linewidth}{!}{\usebox{\mybox}}
      \caption{my sub figure}
      \end{subfigure}
      \begin{subfigure}{0.5\textwidth}
      \resizebox{\linewidth}{!}{\usebox{\mybox}}
      \caption{my sub figure}
      \end{subfigure}
      \begin{subfigure}{0.5\textwidth}
      \resizebox{\linewidth}{!}{\usebox{\mybox}}
      \caption{my sub figure}
      \end{subfigure}
      \begin{subfigure}{0.5\textwidth}
      \resizebox{\linewidth}{!}{\usebox{\mybox}}
      \caption{my sub figure}
      \end{subfigure}
      \caption{Growth of different types foodborne pathogens.}
    \end{figure}

    \end{document}

在此处输入图片描述

相关内容