浮动子图

浮动子图

如您所见,我的图表太大了。我希望它们像“双胞胎”一样浮动,这样如果一页上有很多文本,其他对就会显示在下一页上。有什么解决方案可以将它们设置在正确的位置吗?我尝试使用\minipage\makebox,但出现了一些错误。

在此处输入图片描述

\documentclass{article}

\usepackage{graphicx}
\usepackage{floatrow}
\usepackage{subfig}
\usepackage{tikz,pgfplots,filecontents}
\pgfplotsset{compat=1.7} 
\definecolor{mycolor}{RGB}{32,178,170}
\usepackage[per=slash,
decimalsymbol=comma,
loctolang={DE:ngerman,UK:english}]{siunitx}
\usepackage{float}

\begin{filecontents*}{data1.dat}
X Y
3.07    128316.00
2.05    84349.00
1.02    41565.00
0.51    20906.00
0.26    9756.00
0.17    6948.00
0.09    3079.00
\end{filecontents*}

\begin{filecontents*}{data2.dat}
X Y
3.07    129485
2.05    84605
1.02    41476
0.51    20576
0.26    10144
0.17    6487
0.09    3046
\end{filecontents*}

\begin{filecontents*}{data3.dat}
X Y
3.07    129371
2.05    85244
1.02    41109
0.51    20780
0.26    10275
0.17    6856
0.09    2968
\end{filecontents*}

\begin{filecontents*}{data4.dat}
X Y
3.07    126631
2.05    85450
1.02    41460
0.51    21100
0.26    9997
0.17    6645
0.09    3017
\end{filecontents*}

\begin{filecontents*}{data5.dat}
X Y
3.07    129868
2.05    85627
1.02    41783
0.51    20979
0.26    10033
0.17    6733
0.09    3310
\end{filecontents*}

\begin{filecontents*}{data6.dat}
X Y
3.07    130288
2.05    85342
1.02    42449
0.51    20749
0.26    10026
0.17    6700
0.09    3242
\end{filecontents*}


\begin{document}


\begin{figure}[htbp]
    \begin{floatrow}
        \ffigbox[\FBwidth]
        {
            \subfloat[Kalibration 1]{\begin{tikzpicture}
                \begin{axis}[
                minor tick num=1,
                ymin=0,
                ymax=137000,
                ylabel={Absorption in mAU},
                ytick={0,20000,40000,60000,80000,100000,120000},
                xmin=0,
                xmax=3.6,
                xlabel={Konzentration in \si{\milli\gram\per\milli\liter} },
                axis x line=bottom,
                axis y line=left,
                grid=major,
                legend style={
                    at={(0.55,1)},
                }]
                ]
                \addplot[color=blue,mark=none] coordinates {
                    (0.0164,0)
                    (3.1,129090.97)
                };
                \addplot+[color=red,only marks, mark=x] table[x=X,y=Y] {data1.dat};

                \addlegendentry{y=41864x-687,43}
                \addlegendentry{R$^{2}$=0,9999}
                \end{axis}      
                \end{tikzpicture}}
            \quad
            \subfloat[Kalibration 2]{\begin{tikzpicture}
                \begin{axis}[
                minor tick num=1,
                ymin=0,
                ymax=137000,
                ylabel={Absorption in mAU},
                ytick={0,20000,40000,60000,80000,100000,120000},
                xmin=0,
                xmax=3.6,
                xlabel={Konzentration in \si{\milli\gram\per\milli\liter} },
                axis x line=bottom,
                axis y line=left,
                grid=major,
                legend style={
                    at={(0.55,1)},
                }]
                ]
                \addplot[color=blue,mark=none] coordinates {
                    (0.0164,0)
                    (3.1,129090.97)
                };
                \addplot+[color=red,only marks, mark=x] table[x=X,y=Y] {data2.dat};

                \addlegendentry{y=42248x-951,17}
                \addlegendentry{R$^{2}$=0,9998}
                \end{axis}

                \end{tikzpicture}}
        }{\caption{Captionjö here}}

\end{floatrow}

\begin{floatrow}            
        \ffigbox[\FBwidth]
        {
            \subfloat[Kalibration 3]{\begin{tikzpicture}
                \begin{axis}[
                minor tick num=1,
                ymin=0,
                ymax=137000,
                ylabel={Absorption in mAU},
                ytick={0,20000,40000,60000,80000,100000,120000},
                xmin=0,
                xmax=3.6,
                xlabel={Konzentration in \si{\milli\gram\per\milli\liter} },
                axis x line=bottom,
                axis y line=left,
                grid=major,
                legend style={
                    at={(0.55,1)},
                }]
                ]
                \addplot[color=blue,mark=none] coordinates {
                    (0.0164,0)
                    (3.1,129090.97)
                };
                \addplot+[color=red,only marks, mark=x] table[x=X,y=Y] {data3.dat};

                \addlegendentry{y=42244x-835,73}
                \addlegendentry{R$^{2}$=0,9998}
                \end{axis}          
                \end{tikzpicture}}
        \quad   
        \subfloat[Kalibration 4]{\begin{tikzpicture}
            \begin{axis}[
            minor tick num=1,
            ymin=0,
            ymax=137000,
            ylabel={Absorption in mAU},
            ytick={0,20000,40000,60000,80000,100000,120000},
            xmin=0,
            xmax=3.6,
            xlabel={Konzentration in \si{\milli\gram\per\milli\liter} },
            axis x line=bottom,
            axis y line=left,
            grid=major,
            legend style={
                at={(0.55,1)},
            }]
            ]
            \addplot[color=blue,mark=none] coordinates {
                (0.0164,0)
                (3.1,129090.97)
            };
            \addplot+[color=red,only marks, mark=x] table[x=X,y=Y] {data4.dat};

            \addlegendentry{y=41566x-471,33}
            \addlegendentry{R$^{2}$=0,9999}
            \end{axis}
            \end{tikzpicture}}
            }{\caption{Caption here}}       

\end{floatrow}

\begin{floatrow}            

\ffigbox[\FBwidth]
{
    \subfloat[Kalibration 5]{\begin{tikzpicture}
        \begin{axis}[
        minor tick num=1,
        ymin=0,
        ymax=137000,
        ylabel={Absorption in mAU},
        ytick={0,20000,40000,60000,80000,100000,120000},
        xmin=0,
        xmax=3.6,
        xlabel={Konzentration in \si{\milli\gram\per\milli\liter} },
        axis x line=bottom,
        axis y line=left,
        grid=major,
        legend style={
            at={(0.55,1)},
        }]
        ]
        \addplot[color=blue,mark=none] coordinates {
            (0.0164,0)
            (3.1,129090.97)
        };
        \addplot+[color=red,only marks, mark=x] table[x=X,y=Y] {data5.dat};

        \addlegendentry{y=42410x-758,45}
        \addlegendentry{R$^{2}$=0,9999}
        \end{axis}
        \end{tikzpicture}}
    \quad
    \subfloat[Kalibration 6]{\begin{tikzpicture}
        \begin{axis}[
        minor tick num=1,
        ymin=0,
        ymax=137000,
        ylabel={Absorption in mAU},
        ytick={0,20000,40000,60000,80000,100000,120000},
        xmin=0,
        xmax=3.6,
        xlabel={Konzentration in \si{\milli\gram\per\milli\liter} },
        axis x line=bottom,
        axis y line=left,
        grid=major,
        legend style={
            at={(0.55,1)},
        }]
        ]
        \addplot[color=blue,mark=none] coordinates {
            (0.0164,0)
            (3.1,129090.97)
        };
        \addplot+[color=red,only marks, mark=x] table[x=X,y=Y] {data6.dat};

        \addlegendentry{y=42512x-796,44}
        \addlegendentry{R$^{2}$=0,9999}
        \end{axis}
        \end{tikzpicture}}
}{\caption{Caption here}}       
    \end{floatrow}
\end{figure}
\end{document}

答案1

尽管您已将所有图形成对组织到 中floatrow,但所有图形floatrows都放置在一个 内figure,并且无法在页面之间断开。

floatrow如果您在内部和独立figure环境中声明每个环境,则每个环境figure都会浮动并分布在不同的页面上。

可以使用axis' size选项强制 pgfplots 大小。在本例中,可以是size=.5\textwidth,但由于legend覆盖了部分结果,我还将其移动到legend style={at={(1,1.03)}, anchor=south east,}

结果如下:

在此处输入图片描述

完整代码如下。(顺便说一句,我认为您可以将所有常用轴选项分组到一个pgfplotsset命令中。)

\documentclass{article}
\usepackage{graphicx}

\usepackage{floatrow}
\usepackage{subfig}
\usepackage{tikz,pgfplots,filecontents}
\pgfplotsset{compat=1.7} 
\definecolor{mycolor}{RGB}{32,178,170}
\usepackage[per=slash,
decimalsymbol=comma,
loctolang={DE:ngerman,UK:english}]{siunitx}
\usepackage{float}
\usepackage{lipsum}

\begin{filecontents*}{data1.dat}
X Y
3.07    128316.00
2.05    84349.00
1.02    41565.00
0.51    20906.00
0.26    9756.00
0.17    6948.00
0.09    3079.00
\end{filecontents*}

\begin{filecontents*}{data2.dat}
X Y
3.07    129485
2.05    84605
1.02    41476
0.51    20576
0.26    10144
0.17    6487
0.09    3046
\end{filecontents*}

\begin{filecontents*}{data3.dat}
X Y
3.07    129371
2.05    85244
1.02    41109
0.51    20780
0.26    10275
0.17    6856
0.09    2968
\end{filecontents*}

\begin{filecontents*}{data4.dat}
X Y
3.07    126631
2.05    85450
1.02    41460
0.51    21100
0.26    9997
0.17    6645
0.09    3017
\end{filecontents*}

\begin{filecontents*}{data5.dat}
X Y
3.07    129868
2.05    85627
1.02    41783
0.51    20979
0.26    10033
0.17    6733
0.09    3310
\end{filecontents*}

\begin{filecontents*}{data6.dat}
X Y
3.07    130288
2.05    85342
1.02    42449
0.51    20749
0.26    10026
0.17    6700
0.09    3242
\end{filecontents*}


\begin{document}
\lipsum[2]

\begin{figure}[htbp]
            \subfloat[Kalibration 1]{\begin{tikzpicture}
                \begin{axis}[width=.5\textwidth,
                minor tick num=1,
                ymin=0,
                ymax=137000,
                ylabel={Absorption in mAU},
                ytick={0,20000,40000,60000,80000,100000,120000},
                xmin=0,
                xmax=3.6,
                xlabel={Konzentration in \si{\milli\gram\per\milli\liter} },
                axis x line=bottom,
                axis y line=left,
                grid=major,
                legend style={
                    at={(1,1.03)}, anchor=south east,
                }]
                ]
                \addplot[color=blue,mark=none] coordinates {
                    (0.0164,0)
                    (3.1,129090.97)
                };
                \addplot+[color=red,only marks, mark=x] table[x=X,y=Y] {data1.dat};

                \addlegendentry{y=41864x-687,43}
                \addlegendentry{R$^{2}$=0,9999}
                \end{axis}      
                \end{tikzpicture}}
\hfill
            \subfloat[Kalibration 2]{\begin{tikzpicture}
                \begin{axis}[width=.5\textwidth,
                minor tick num=1,
                ymin=0,
                ymax=137000,
                ylabel={Absorption in mAU},
                ytick={0,20000,40000,60000,80000,100000,120000},
                xmin=0,
                xmax=3.6,
                xlabel={Konzentration in \si{\milli\gram\per\milli\liter} },
                axis x line=bottom,
                axis y line=left,
                grid=major,
                legend style={
                    at={(1,1.03)}, anchor=south east,
                }]
                ]
                \addplot[color=blue,mark=none] coordinates {
                    (0.0164,0)
                    (3.1,129090.97)
                };
                \addplot+[color=red,only marks, mark=x] table[x=X,y=Y] {data2.dat};

                \addlegendentry{y=42248x-951,17}
                \addlegendentry{R$^{2}$=0,9998}
                \end{axis}
                \end{tikzpicture}}
    \caption{Captionjö here}
\end{figure}

\lipsum[1]

\begin{figure}
            \subfloat[Kalibration 3]{\begin{tikzpicture}
                \begin{axis}[width=.5\textwidth,
                minor tick num=1,
                ymin=0,
                ymax=137000,
                ylabel={Absorption in mAU},
                ytick={0,20000,40000,60000,80000,100000,120000},
                xmin=0,
                xmax=3.6,
                xlabel={Konzentration in \si{\milli\gram\per\milli\liter} },
                axis x line=bottom,
                axis y line=left,
                grid=major,
                legend style={
                    at={(1,1.03)}, anchor=south east
                }]
                ]
                \addplot[color=blue,mark=none] coordinates {
                    (0.0164,0)
                    (3.1,129090.97)
                };
                \addplot+[color=red,only marks, mark=x] table[x=X,y=Y] {data3.dat};

                \addlegendentry{y=42244x-835,73}
                \addlegendentry{R$^{2}$=0,9998}
                \end{axis}          
                \end{tikzpicture}}
        \hfill
        \subfloat[Kalibration 4]{\begin{tikzpicture}
            \begin{axis}[width=.5\textwidth,
            minor tick num=1,
            ymin=0,
            ymax=137000,
            ylabel={Absorption in mAU},
            ytick={0,20000,40000,60000,80000,100000,120000},
            xmin=0,
            xmax=3.6,
            xlabel={Konzentration in \si{\milli\gram\per\milli\liter} },
            axis x line=bottom,
            axis y line=left,
            grid=major,
            legend style={
                at={(1,1.03)}, anchor=south east
            }]
            ]
            \addplot[color=blue,mark=none] coordinates {
                (0.0164,0)
                (3.1,129090.97)
            };
            \addplot+[color=red,only marks, mark=x] table[x=X,y=Y] {data4.dat};

            \addlegendentry{y=41566x-471,33}
            \addlegendentry{R$^{2}$=0,9999}
            \end{axis}
            \end{tikzpicture}}
            \caption{Caption here}
\end{figure}

\lipsum[2]

\begin{figure}            
    \subfloat[Kalibration 5]{\begin{tikzpicture}
        \begin{axis}[width=.5\textwidth,
        minor tick num=1,
        ymin=0,
        ymax=137000,
        ylabel={Absorption in mAU},
        ytick={0,20000,40000,60000,80000,100000,120000},
        xmin=0,
        xmax=3.6,
        xlabel={Konzentration in \si{\milli\gram\per\milli\liter} },
        axis x line=bottom,
        axis y line=left,
        grid=major,
        legend style={
            at={(1,1.03)}, anchor=south east
        }]
        ]
        \addplot[color=blue,mark=none] coordinates {
            (0.0164,0)
            (3.1,129090.97)
        };
        \addplot+[color=red,only marks, mark=x] table[x=X,y=Y] {data5.dat};

        \addlegendentry{y=42410x-758,45}
        \addlegendentry{R$^{2}$=0,9999}
        \end{axis}
        \end{tikzpicture}}\hfill
    \subfloat[Kalibration 6]{\begin{tikzpicture}
        \begin{axis}[width=.5\textwidth,
        minor tick num=1,
        ymin=0,
        ymax=137000,
        ylabel={Absorption in mAU},
        ytick={0,20000,40000,60000,80000,100000,120000},
        xmin=0,
        xmax=3.6,
        xlabel={Konzentration in \si{\milli\gram\per\milli\liter} },
        axis x line=bottom,
        axis y line=left,
        grid=major,
        legend style={
            at={(1,1.03)}, anchor=south east
        }]
        ]
        \addplot[color=blue,mark=none] coordinates {
            (0.0164,0)
            (3.1,129090.97)
        };
        \addplot+[color=red,only marks, mark=x] table[x=X,y=Y] {data6.dat};

        \addlegendentry{y=42512x-796,44}
        \addlegendentry{R$^{2}$=0,9999}
        \end{axis}
        \end{tikzpicture}}
\caption{Caption here}       
\end{figure}
\end{document}

相关内容