【发布时间】:2020-05-18 17:54:46
【问题描述】:
我有多个数据文件(result_a.csv、result_b.csv、..),我想为每个文件创建图(result_a.pdf、result_b.pdf - 或类似文件)。绘图相同,但输入文件不同,输出文件不同。有没有办法可以运行循环,从外部传递参数名称并使用独特的名称保存输出?
假设我创建情节的代码 -
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{ytick style={draw=none}, xtick style={draw=none}}
\usetikzlibrary{patterns}
\newcommand\param{a}
\begin{document}
\begin{tikzpicture}
\footnotesize
\begin{semilogxaxis}
\addplot[color=red,mark=triangle] table [x=x,y=y,col sep=comma, mark=*] {result_\param.csv};
\end{semilogxaxis}
\end{tikzpicture}
\end{document}
【问题讨论】:
-
如果您在 Linux 发行版或 Mac OS 下工作,您可以使用 shell 脚本来创建 result_a.tex、result_b.tex,...并在同一脚本中编译 tex 文件用于所需的输出 pdf。也许在 Windows 下你也可以采用类似的方法。
-
谢谢@Eddymage,我正在使用mac os,请您提示我有关脚本的信息
-
我会将其作为答案发布,以使其尽可能清晰。
-
另一种可能的方法是只有一个 tex 文档循环所有 cvs 文件并使用 tikz externalise 库为每个绘图生成单独的文件。