LaTeX 能创建带有数学曲线的图形吗?

LaTeX 能创建带有数学曲线的图形吗?

我正在尝试看看 LaTeX 有多好。

有人能告诉我图形是否像这样吗?

谢谢您因版权投诉删除了该图。

答案1

正如其他人提到的,您可以使用 tikz,它有一个很棒的手册。

你也可以用 Matlab 画图,然后用 matlab2tikz 生成 latex 代码。下面是一个绘制三个子图和一个图例的示例。

\documentclass[a4paper,11pt]{article}

\usepackage[margin=1.5cm]{geometry}

\usepackage{pgfplots}
%\usepackage{tikz}
%\usetikzlibrary{plotmarks}

\begin{document}

\begin{figure*}[t!]
\centering
%\vspace{-0.6cm}
% This file was created by matlab2tikz v0.4.0.
% Copyright (c) 2008--2013, Nico Schlömer <[email protected]>
% All rights reserved.
% 
% The latest updates can be retrieved from
%   http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz
% where you can also make suggestions and rate matlab2tikz.
% 
% 
% 
\begin{tikzpicture}

\begin{axis}[%
width=7cm,
height=5cm,
scale only axis,
xmin=0.9,
xmax=3.1,
xtick={1,2,3},
xticklabels={5,10,20},
ymin=0.2,
ymax=0.489263081879195,
ylabel={y label bla bla},
name=plot1
]
\addplot [
color=blue,
solid,
mark size=3.3pt,
mark=triangle,
mark options={solid,,rotate=180},
forget plot
]
table[row sep=crcr]{
1 0.290207259060403\\
2 0.288066603131991\\
};
\addplot [
color=green,
solid,
mark size=5.0pt,
mark=o,
mark options={solid},
forget plot
]
table[row sep=crcr]{
1 0.302183970469799\\
2 0.294949917673378\\
3 0.285995259955257\\
};
\addplot [
color=red,
solid,
mark size=5.0pt,
mark=asterisk,
mark options={solid},
forget plot
]
table[row sep=crcr]{
2 0.295317844295302\\
3 0.294641009395973\\
};
\addplot [
color=blue,
dashed,
mark size=3.3pt,
mark=triangle,
mark options={solid,,rotate=180},
forget plot
]
table[row sep=crcr]{
1 0.278730545861298\\
2 0.277802096644295\\
};
\addplot [
color=green,
dashed,
mark size=5.0pt,
mark=o,
mark options={solid},
forget plot
]
table[row sep=crcr]{
1 0.280238520805369\\
2 0.285091444295302\\
3 0.277355641163311\\
};
\addplot [
color=red,
dashed,
mark size=5.0pt,
mark=asterisk,
mark options={solid},
forget plot
]
table[row sep=crcr]{
2 0.279342850111857\\
3 0.267745444295302\\
};
\addplot [
color=black,
dash pattern=on 1pt off 3pt on 3pt off 3pt,
line width=1.5pt,
forget plot
]
table[row sep=crcr]{
1 0.207873194630872\\
2 0.207873194630872\\
3 0.207873194630872\\
};
\addplot [
color=black,
dotted,
line width=1.5pt,
forget plot
]
table[row sep=crcr]{
1 0.469263081879195\\
2 0.469263081879195\\
3 0.469263081879195\\
};
\end{axis}

\begin{axis}[%
xshift=0.5cm,
width=7cm,
height=5cm,
scale only axis,
xmin=0.9,
xmax=3.1,
xtick={1,2,3},
xticklabels={5,10,20},
ymin=0,
ymax=6,
ylabel={y label bla bla},
at=(plot1.right of south east),
anchor=left of south west
]
\addplot [
color=blue,
solid,
mark size=3.3pt,
mark=triangle,
mark options={solid,,rotate=180},
forget plot
]
table[row sep=crcr]{
1 3.0579222\\
2 3.27228546666667\\
};
\addplot [
color=green,
solid,
mark size=5.0pt,
mark=o,
mark options={solid},
forget plot
]
table[row sep=crcr]{
1 3.678485\\
2 1.78462153333333\\
3 0.132394466666667\\
};
\addplot [
color=red,
solid,
mark size=5.0pt,
mark=asterisk,
mark options={solid},
forget plot
]
table[row sep=crcr]{
2 0.335520333333333\\
3 0.106502666666667\\
};
\addplot [
color=blue,
dashed,
mark size=3.3pt,
mark=triangle,
mark options={solid,,rotate=180},
forget plot
]
table[row sep=crcr]{
1 5.1519882\\
2 2.3329078\\
};
\addplot [
color=green,
dashed,
mark size=5.0pt,
mark=o,
mark options={solid},
forget plot
]
table[row sep=crcr]{
1 2.875987\\
2 2.722576\\
3 0.268442533333333\\
};
\addplot [
color=red,
dashed,
mark size=5.0pt,
mark=asterisk,
mark options={solid},
forget plot
]
table[row sep=crcr]{
2 0.1976194\\
3 0.0553086666666667\\
};
\addplot [
color=black,
dash pattern=on 1pt off 3pt on 3pt off 3pt,
line width=1.5pt,
forget plot
]
table[row sep=crcr]{
1 4.34113352673945\\
2 4.34113352673945\\
3 4.34113352673945\\
};
\end{axis}

\begin{axis}[%
width=7cm,
height=5cm,
scale only axis,
xmin=0.9,
xmax=3.1,
xtick={1,2,3},
xticklabels={5,10,20},
xlabel={x label bla},
ymin=0,
ymax=20,
ylabel={y label bla},
at=(plot1.below south west),
anchor=above north west,
legend style={at={(1.4,0.5)},anchor=west,draw=black,fill=white,legend cell align=left}
]
\addplot [
color=blue,
solid,
mark size=3.3pt,
mark=triangle,
mark options={solid,,rotate=180}
]
table[row sep=crcr]{
1 19.8\\
2 18.7333333333333\\
};
\addlegendentry{curve 1};

\addplot [
color=green,
solid,
mark size=5.0pt,
mark=o,
mark options={solid}
]
table[row sep=crcr]{
1 15\\
2 13.4\\
3 14.2666666666667\\
};
\addlegendentry{curve 2};

\addplot [
color=red,
solid,
mark size=5.0pt,
mark=asterisk,
mark options={solid}
]
table[row sep=crcr]{
2 11.8666666666667\\
3 11.5333333333333\\
};
\addlegendentry{curve 3};

\addplot [
color=blue,
dashed,
mark size=3.3pt,
mark=triangle,
mark options={solid,,rotate=180}
]
table[row sep=crcr]{
1 16.2666666666667\\
2 17.2\\
};
\addlegendentry{curve 4};

\addplot [
color=green,
dashed,
mark size=5.0pt,
mark=o,
mark options={solid}
]
table[row sep=crcr]{
1 12.1333333333333\\
2 11.9333333333333\\
3 13.4\\
};
\addlegendentry{curve 5};

\addplot [
color=red,
dashed,
mark size=5.0pt,
mark=asterisk,
mark options={solid}
]
table[row sep=crcr]{
2 10.8666666666667\\
3 10.7333333333333\\
};
\addlegendentry{curve 6};

\addplot [
color=black,
dash pattern=on 1pt off 3pt on 3pt off 3pt,
line width=1.5pt
]
table[row sep=crcr]{
1 14\\
2 14\\
3 14\\
};
\addlegendentry{some curve};

\addplot [
color=black,
dotted,
line width=1.5pt
]
table[row sep=crcr]{
1 2\\
2 2\\
3 2\\
};
\addlegendentry{some other curve};

\end{axis}
\end{tikzpicture}%
\caption{Caption goes here}
\label{fig:some_label}
\end{figure*}

\end{document}

相关内容