当我使用我的代码时,总是说-编译超时-www.overleaf.com/ 我检查了两次我的代码并没有发现任何错误
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{caption} % <----
\captionsetup{font = small} % <----
\usepackage[active,floats,tightpage]{preview}% <---
\setlength\PreviewBorder{1em}
\begin{document}
%---------------------------------------------------------------%
\begin{figure} % <---
\centering % <---
\begin{tikzpicture}
%%%% f1
\begin{axis}[scale only axis,
xlabel=Time,
xmin=0, xmax=168,
ylabel={log(Cfu/cm$^{2}$)},
axis y line*=left,
ymin=0, ymax=10,
legend style={at={(0.48,-0.15)}, % <---
anchor=north east}] % <---
\addplot [black, fill=white, mark=square*]
table[row sep=crcr]{
0 7.005\\
2 7\\
4 7.035\\
6 7.005\\
8 7.015\\
10 7.025\\
12 6.98\\
14 6.985\\
16 6.94\\
18 6.89\\
20 6.81\\
22 6.63\\
24 6.46\\
48 5.945\\
72 6.445\\
168 6.845\\};
\addplot [black, fill=white, mark=*]
table[row sep=crcr]{
0 7\\
2 7.02\\
4 7.03\\
6 7.01\\
8 7.025\\
10 7.03\\
12 6.98\\
14 6.92\\
16 6.895\\
18 6.78\\
20 6.62\\
22 6.415\\
24 6.205\\
48 6.37\\
72 6.49\\
168 6.865\\};
\addplot [black, fill=white, mark=diamond*]
table[row sep=crcr]{
0 7.01\\
2 7.02\\
4 7.045\\
6 7.01\\
8 7.03\\
10 7.025\\
12 6.98\\
14 6.955\\
16 6.905\\
18 6.825\\
20 6.725\\
22 6.575\\
24 6.43\\
48 6.27\\
72 6.345\\
168 6.975\\};
\addlegendentry{plot 3} % <---
\addplot [black, fill=white, mark=triangle*]
table[row sep=crcr]{
0 7.005\\
2 7.02\\
4 7.03\\
6 7.02\\
8 7.01\\
10 7.02\\
12 6.99\\
14 6.975\\
16 6.93\\
18 6.845\\
20 6.715\\
22 6.53\\
24 6.315};
48 6.32\\
72 6.405\\
168 6.785\\};
\label{plot_one}
\addlegendentry{plot 4}
\end{axis}
%%%% f2
\begin{axis}[scale only axis,
hide x axis,
xmin=0, xmax=168,
ylabel={Relative Expression},
axis y line*=right,
ymin=0, ymax=6,
legend style={at={(0.52,-0.15)}, % <---
anchor=north west}]% <---
]
% \addlegendimage{/pgfplots/refstyle=plot_one}
\addplot [black, mark=square*]
table[row sep=crcr]{
0 0.051\\
2 0.0175\\
4 0.0945\\
6 0.122\\
8 0.135\\
10 0.14\\
12 0.1745\\
14 0.1855\\
16 0.29\\
18 0.423\\
20 0.574\\
22 0.8165\\
24 1.061\\
48 1.985\\
72 2.0285\\
168 1.9215\\};
\addplot [black, mark=*]
table[row sep=crcr]{
0 1.6\\
0 0.052\\
2 0.0165\\
4 0.1495\\
6 0.1805\\
8 0.1835\\
10 0.1855\\
12 0.2005\\
14 0.3795\\
16 0.5425\\
18 0.8065\\
20 1.046\\
22 1.2005\\
24 1.483\\
48 2.369\\
72 2.0315\\
168 2.3025\\};
\addplot [black, mark=diamond*]
table[row sep=crcr]{
0 0.053\\
2 0.0485\\
4 0.1365\\
6 0.164\\
8 0.1595\\
10 0.1725\\
12 0.1935\\
14 0.2315\\
16 0.3345\\
18 0.473\\
20 0.6015\\
22 0.8185\\
24 1.0415\\
48 2.082\\
72 1.919\\
168 1.711\\};
\addlegendentry{plot 3} % <---
\addplot [black, mark=triangle*]
table[row sep=crcr]{
0 0.0525\\
2 0.0325\\
4 0.0285\\
6 0.108\\
8 0.1255\\
10 0.1475\\
12 0.1405\\
14 0.2495\\
16 0.3955\\
18 0.529\\
20 0.7175\\
22 0.9715\\
24 1.2455\\
48 1.94\\
72 1.696\\
168 1.942\\};
\label{plot_four}
\addlegendentry{plot 4} % <---
\end{axis}
\end{tikzpicture}
\caption{Growth of different types foodborne pathogens.} % <---
\end{figure} % <---
\end{document}
答案1
永远循环下去
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{caption} % <----
\captionsetup{font = small} % <----
\usepackage[active,floats,tightpage]{preview}% <---
\setlength\PreviewBorder{1em}
\begin{document}
%---------------------------------------------------------------%
\begin{figure} % <---
\centering % <---
\begin{tikzpicture}
%%%% f1
\begin{axis}[scale only axis,
xlabel=Time,
xmin=0, xmax=168,
ylabel={log(Cfu/cm$^{2}$)},
axis y line*=left,
ymin=0, ymax=10,
legend style={at={(0.48,-0.15)}, % <---
anchor=north east}] % <---
\addplot [black, fill=white, mark=square*]
table[row sep=crcr]{
0 7.005\\
2 7\\
4 7.035\\
6 7.005\\
8 7.015\\
10 7.025\\
12 6.98\\
14 6.985\\
16 6.94\\
18 6.89\\
20 6.81\\
22 6.63\\
24 6.46\\
48 5.945\\
72 6.445\\
168 6.845\\};
\addplot [black, fill=white, mark=*]
table[row sep=crcr]{
0 7\\
2 7.02\\
4 7.03\\
6 7.01\\
8 7.025\\
10 7.03\\
12 6.98\\
14 6.92\\
16 6.895\\
18 6.78\\
20 6.62\\
22 6.415\\
24 6.205\\
48 6.37\\
72 6.49\\
168 6.865\\};
\addplot [black, fill=white, mark=diamond*]
table[row sep=crcr]{
0 7.01\\
2 7.02\\
4 7.045\\
6 7.01\\
8 7.03\\
10 7.025\\
12 6.98\\
14 6.955\\
16 6.905\\
18 6.825\\
20 6.725\\
22 6.575\\
24 6.43\\
48 6.27\\
72 6.345\\
168 6.975\\};
\addlegendentry{plot 3} % <---
\addplot [black, fill=white, mark=triangle*]
table[row sep=crcr]{
0 7.005\\
2 7.02\\
4 7.03\\
6 7.02\\
8 7.01\\
10 7.02\\
12 6.99\\
14 6.975\\
16 6.93\\
18 6.845\\
20 6.715\\
22 6.53\\
24 6.315};
48 6.32\\
72 6.405\\
168 6.785\\};
\label{plot_one}
\addlegendentry{plot 4}
\end{axis}
%%%% f2
\end{tikzpicture}
\caption{Growth of different types foodborne pathogens.} % <---
\end{figure} % <---
\end{document}
但如果你改变
最后一部分
24 6.315};
48 6.32\\
72 6.405\\
168 6.785\\};
到
24 6.315\\};
然后它就运行了。