如何在同一页面和位置添加两个彼此相邻的图表?

如何在同一页面和位置添加两个彼此相邻的图表?

在此处输入图片描述 有人能告诉我如何绘制两个并排的带有图例的图表吗?我从 .dat 文件中读取了数据。有人能告诉我如何为两个图表添加标签吗?我附上了一个图表应该是什么样子的示例。我的代码如下:

\documentclass[12pt, a4paper]{report}
\usepackage{filecontents,pgfplots}

\begin{filecontents}{mydata.dat}
m0_FEED, AT 773.15K, AT 823.15K, AT 873.15K, AT 923.15K, AT 973.15K
0.005, 1.30E+04, 12959.71536,12959.71536,12959.71536,12959.71536
0.007, 1.81E+04, 18145.78478,18145.78478,18145.78478,18145.784
0.009, 2.33E+04, 23333.9541,23333.9541,23333.9541,23333.9541
0.011, 2.85E+04, 28524.71381,28524.71381,28524.71381,28524.71381
0.013, 3.37E+04, 33718.48576,33718.48576,33718.48576,33718.48576
0.015, 3.89E+04, 38915.61947,38915.61947,38915.61947,38915.61947
0.017, 4.41E+04, 44116.39602,44116.39603,44116.39603,44116.39603
0.019, 4.93E+04, 49321.02848,49321.02848,49321.02878,49321.02849
0.021, 5.45E+04, 54529.67237,54529.67238,54529.67238,54529.67238
\end{filecontents}



\begin{document}
\pgfplotstableread[col sep=comma]{mydata.dat}{\mydata}
\begin{tikzpicture}[scale=1.5]
\begin{axis}[grid=major,legend style={nodes={scale=0.5, transform shape}},legend pos=north west, minor tick num=1,
xlabel=Flowrate ($mol/s$), ylabel = temperature (K), legend entries={AT773.15K, AT823.15K, AT873.15K, AT923.15K, AT973.15K}]
\addplot [black,mark=square] table [x={m0_FEED}, y={AT 773.15K}] {\mydata};
\addplot [red,mark=*] table [x={m0_FEED}, y={AT 823.15K}] {\mydata};
\addplot [blue,mark=triangle] table [x={m0_FEED}, y={AT 873.15K}] {\mydata};
\addplot [green,mark=diamond] table [x={m0_FEED}, y={AT 923.15K}] {\mydata};
\addplot [orange,mark=x] table [x={m0_FEED}, y={AT 973.15K}] {\mydata};
\legend{AT773.15K, AT823.15K, AT873.15K, AT923.15K, AT973.15K}
\end{axis}
\end{tikzpicture}
\begin{filecontents}{Book.dat}
m0_FEED,AT 773.15K,AT 823.15K,AT 873.15K,AT 923.15K,AT 973.15K
0.005,4.06E+03,4601.511738,5147.966831,5703.120845,6267.035737
0.007,5.69E+03,6439.241858,7204.278989,7981.494608,8625.923
0.009,7.31E+03,8274.205759,9257.824928,10257.10215,11272.14896
0.011,8.92E+03,10105.75535,11307.95656,12529.29539,13769.90815
0.013,1.05E+04,11933.33165,13354.1149,14797.51533,16263.69405
0.015,1.21E+04,13756.46929,15395.83457,17061.29661,18753.04129
0.017,1.37E+04,15574.79159,17432.7389,19320.26254,21237.57317
0.019,1.53E+04,17388.009,19464.53834,21574.12348,23717.00014
0.021,1.69E+04,19195.90581,21491.01717,23822.664,26191.10653

\end{filecontents}

\pgfplotstableread[col sep=comma]{Book.dat}{\Book}
\begin{tikzpicture}[scale=1.5]

\begin{axis}[grid=major,legend style={nodes={scale=0.5, transform shape}},legend pos=north west, minor tick num=1,
xlabel=Flowrate ($mol/s$), ylabel = temperature (K), legend entries={AT773.15K, AT823.15K, AT873.15K, AT923.15K, AT973.15K}]
\addplot [black,mark=square] table [x={m0_FEED}, y={AT 773.15K}] {\Book};
\addplot [red,mark=*] table [x={m0_FEED}, y={AT 823.15K}] {\Book};
\addplot [blue,mark=triangle] table [x={m0_FEED}, y={AT 873.15K}] {\Book};
\addplot [green,mark=diamond] table [x={m0_FEED}, y={AT 923.15K}] {\Book};
\addplot [orange,mark=x] table [x={m0_FEED}, y={AT 973.15K}] {\Book};
%\legend{AT773.15K, AT823.15K, AT873.15K, AT923.15K, AT973.15K}
\end{axis}
\end{tikzpicture}


\end{document}

答案1

像这样 ?

我将这两个图表放在同一个tikzpicture环境中,由于它们太大,无法在页面上容纳,因此我将它们缩小到四分之三。

为了让您判断布局,我绘制了包装的边距showframe

截屏

\documentclass[12pt, a4paper]{report}
\usepackage{filecontents,pgfplots}
\usepackage{showframe}

\begin{filecontents}{mydata.dat}
m0_FEED, AT 773.15K, AT 823.15K, AT 873.15K, AT 923.15K, AT 973.15K
0.005, 1.30E+04, 12959.71536,12959.71536,12959.71536,12959.71536
0.007, 1.81E+04, 18145.78478,18145.78478,18145.78478,18145.784
0.009, 2.33E+04, 23333.9541,23333.9541,23333.9541,23333.9541
0.011, 2.85E+04, 28524.71381,28524.71381,28524.71381,28524.71381
0.013, 3.37E+04, 33718.48576,33718.48576,33718.48576,33718.48576
0.015, 3.89E+04, 38915.61947,38915.61947,38915.61947,38915.61947
0.017, 4.41E+04, 44116.39602,44116.39603,44116.39603,44116.39603
0.019, 4.93E+04, 49321.02848,49321.02848,49321.02878,49321.02849
0.021, 5.45E+04, 54529.67237,54529.67238,54529.67238,54529.67238
\end{filecontents}
\pgfplotstableread[col sep=comma]{mydata.dat}{\mydata}

\begin{filecontents}{Book.dat}
m0_FEED,AT 773.15K,AT 823.15K,AT 873.15K,AT 923.15K,AT 973.15K
0.005,4.06E+03,4601.511738,5147.966831,5703.120845,6267.035737
0.007,5.69E+03,6439.241858,7204.278989,7981.494608,8625.923
0.009,7.31E+03,8274.205759,9257.824928,10257.10215,11272.14896
0.011,8.92E+03,10105.75535,11307.95656,12529.29539,13769.90815
0.013,1.05E+04,11933.33165,13354.1149,14797.51533,16263.69405
0.015,1.21E+04,13756.46929,15395.83457,17061.29661,18753.04129
0.017,1.37E+04,15574.79159,17432.7389,19320.26254,21237.57317
0.019,1.53E+04,17388.009,19464.53834,21574.12348,23717.00014
0.021,1.69E+04,19195.90581,21491.01717,23822.664,26191.10653

\end{filecontents}

\pgfplotstableread[col sep=comma]{Book.dat}{\Book}

\begin{document}

\begin{tikzpicture}[scale=.75]
\begin{axis}[grid=major,legend style={nodes={scale=0.5, transform shape}},legend pos=north west, minor tick num=1,
xlabel=Flowrate ($mol/s$), ylabel = temperature (K), legend entries={AT773.15K, AT823.15K, AT873.15K, AT923.15K, AT973.15K}]
\addplot [black,mark=square] table [x={m0_FEED}, y={AT 773.15K}] {\mydata};
\addplot [red,mark=*] table [x={m0_FEED}, y={AT 823.15K}] {\mydata};
\addplot [blue,mark=triangle] table [x={m0_FEED}, y={AT 873.15K}] {\mydata};
\addplot [green,mark=diamond] table [x={m0_FEED}, y={AT 923.15K}] {\mydata};
\addplot [orange,mark=x] table [x={m0_FEED}, y={AT 973.15K}] {\mydata};
\legend{AT773.15K, AT823.15K, AT873.15K, AT923.15K, AT973.15K}
\end{axis}
%\end{tikzpicture}
%
%\begin{tikzpicture}[scale=1.5]

\begin{axis}[xshift=8cm,grid=major,legend style={nodes={scale=0.5, transform shape}},legend pos=north west, minor tick num=1,
xlabel=Flowrate ($mol/s$), ylabel = temperature (K), legend entries={AT773.15K, AT823.15K, AT873.15K, AT923.15K, AT973.15K}]
\addplot [black,mark=square] table [x={m0_FEED}, y={AT 773.15K}] {\Book};
\addplot [red,mark=*] table [x={m0_FEED}, y={AT 823.15K}] {\Book};
\addplot [blue,mark=triangle] table [x={m0_FEED}, y={AT 873.15K}] {\Book};
\addplot [green,mark=diamond] table [x={m0_FEED}, y={AT 923.15K}] {\Book};
\addplot [orange,mark=x] table [x={m0_FEED}, y={AT 973.15K}] {\Book};
%\legend{AT773.15K, AT823.15K, AT873.15K, AT923.15K, AT973.15K}
\end{axis}
\end{tikzpicture}


\end{document}

相关内容