我正在 groupplots
策划这
数据集相当大(每个图 15000 个数据点,每组有 5 个这样的图)。当 Latex 抛出内存不足错误时,我尝试使用 tikz 的外部化。但是当我pdflatex -shell-escape <filename>
从命令行编译时,我收到以下错误
! Package tikz Error: Sorry, the system call 'pdflatex -shell-escape -halt-on-e
rror -interaction=batchmode -jobname "Second_phase_updates-figure5" "\def\tikze
xternalrealjob{Second_phase_updates}\input{Second_phase_updates}"' did NOT resu
lt in a usable output file 'Second_phase_updates-figure5' (expected one of .pdf
:.jpg:.jpeg:.png:). Please verify that you have enabled system calls. For pdfla
tex, this is 'pdflatex -shell-escape'. Sometimes it is also named 'write 18' or
something like that. Or maybe the command simply failed? Error messages can be
found in 'Second_phase_updates-figure5.log'. If you continue now, I'll try to
typeset the picture.
See the tikz package documentation for explanation.
Type H <return> for immediate help.
...
l.265 \end{tikzpicture}
?
帮我解决这个错误。这不是任何内容的重复。在发布此信息之前,我已经尝试了所有可能的建议解决方案。
这里我包含了一个 MWE。
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepgfplotslibrary{groupplots}
\usepackage{tikz}
\usepgfplotslibrary{external}
\tikzexternalize
\tikzset{external/force remake}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\begin{groupplot}[
group style={
group size=1 by 2, % sets number of columns and rows in groupplot array
vertical sep=0pt, % vertical distance between axes
},
axis y line=left, % y axis line on left side only
xmin=0,xmax=1000, % set axis
ymin=0, % limits
domain=1:9, % domain, just for example
width=15cm, % width
height=5cm, % and height for each axis
scale only axis, % disregard labels and ticks for scaling
no markers,
enlarge y limits=upper,
]
\nextgroupplot[
ylabel=$SPL(dB)$,
ylabel style={at={(rel axis cs:0,1)},above,rotate=-90}, %move ylabel a bit
axis x line=none] % remove x-axis lines
\addplot table [y=p5, x=frequency]{1m_f2800.txt};
\nextgroupplot[axis x line=none]
\addplot [y=p4, x=frequency]{1m_f2800.txt};
\nextgroupplot[axis x line=none]
\addplot [y=p3, x=frequency]{1m_f2800.txt};
\nextgroupplot[axis x line=none]
\addplot [y=p2, x=frequency]{1m_f2800.txt};
\nextgroupplot[
axis x line=bottom, % only x axis line at bottom
xlabel=$Frequency$,
%xlabel style={at={(rel axis cs:1,0)},right}]
\addplot table [y=p1, x=frequency]{1m_f2800.txt};
\end{groupplot}
\end{tikzpicture}
\end{figure}
\end{document}
可以找到数据文件这里
答案1
Tikz 外部化无法解决内存问题,因为它所做的是在编译后将 tikzpicture 环境的输出保存为外部文件(pdf 或 eps)。如果您的代码无法编译,则无法外部化任何内容。
纠正语法错误后(请阅读错误消息!),它会使用 LuaLatex 为我编译。但您还应该检查 groupplot 命令,这会给出额外的警告消息。您只是定义了一个 1x2 矩阵,但添加了远不止两个图!
代码
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepgfplotslibrary{groupplots}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[
group style={
group size=1 by 5, % sets number of columns and rows in groupplot array
vertical sep=10pt, % vertical distance between axes
},
axis y line=left, % y axis line on left side only
xmin=0,xmax=1000, % set axis
ymin=0, % limits
domain=1:9, % domain, just for example
width=15cm, % width
height=5cm, % and height for each axis
scale only axis, % disregard labels and ticks for scaling
no markers,
enlarge y limits=upper,
]
%
\nextgroupplot[
ylabel=$SPL$ (dB),
ylabel style={at={(rel axis cs:0,1)},above,rotate=-90}, %move ylabel a bit
axis x line=none % remove x-axis lines
]
\addplot table [y=p5, x=frequency]{1m_f2800.txt};
%
\nextgroupplot[axis x line=none]
\addplot table [y=p4, x=frequency]{1m_f2800.txt};
%
\nextgroupplot[axis x line=none]
\addplot table [y=p3, x=frequency]{1m_f2800.txt};
%
\nextgroupplot[axis x line=none]
\addplot table [y=p2, x=frequency]{1m_f2800.txt};
%
\nextgroupplot[
axis x line=bottom, % only x axis line at bottom
xlabel=Frequency,
%xlabel style={at={(rel axis cs:1,0)},right}
]
\addplot table [y=p1, x=frequency]{1m_f2800.txt};
%
\end{groupplot}
%
\end{tikzpicture}
%
\end{document}