\usepackage{pgfplots} %引用包
\pgfplotsset{compat=newest}
% compat 指定 pgfplots 的版本, 这里用最新。也可以直接用版本号,如1.13
%如果不指定新版本, y与z可能会重合。
\begin{figure}[!h] %插入图片
\centering %图片居中
\begin{tikzpicture} %tikz图片
\begin{axis}[
axis y line*=left,%y轴居左
xlabel=x, %横坐标名
ylabel=y, %纵坐标名
tick align=outside, %刻度在外显式
]
%第一条线,mark是折线标示形状
\addplot[smooth,mark=*,blue] plot coordinates {
(20,1)
(40,2)
(60,3)
(80,4)
(100,5)
};
%图例里名字
\label{plot_one}
%第二条线,mark是折线标示形状
\addplot[smooth,mark=triangle,cyan] plot coordinates {
(20,1.3)
(40,2.3)
(60,3.3)
(80,4.3)
(100,5.3)
};
\label{plot_two}
\end{axis}
%第三条线, 用另一个y轴