我有以下代码在乳胶中绘制 4 个文本文件
\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[tick pos=left,name=plot, xlabel={Distance $\mu$m},ylabel={Contrast},
xmin=300,xmax=500,ymin=750,ymax=950]
% Indifference curves
\addplot[coordinate style/.from={0},smooth = 6,color = black] table{./1L 4.txt};
\addplot[color = red] table{./2L 4.txt};
\addplot[color = green] table{./3L 4.txt};
\addplot[color = blue] table{./4L 4.txt};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
答案1
\begin{filecontents}{1L 4.txt}
300 760
350 770
370 850
390 770
410 840
430 770
500 760
\end{filecontents}
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
tick pos=left,
xlabel={Distance $\mu$m}, ylabel={Contrast},
xmin=300, xmax=500,
ymin=750, ymax=950,
smooth, thick,
ytick=\empty,
]
\addplot[black] table {./1L 4.txt};
\addplot[red] table[y expr={\thisrowno{1}+20}] {./1L 4.txt};
\addplot[green] table[y expr={\thisrowno{1}+40}] {./1L 4.txt};
\addplot[blue] table[y expr={\thisrowno{1}+60}] {./1L 4.txt};
\end{axis}
\end{tikzpicture}
\end{document}