我正在尝试编写一个示例代码,用作模板来生成稍后将包含在论文中的图片。在此阶段,图片只是情节。
我有以下代码。但它不遵守指定的\paperwidth
和\paperheight
。缺少什么?
\documentclass{standalone}
\usepackage{geometry}
\geometry{%
paperwidth=52.65mm,
paperheight=47.75mm,
margin=0mm,
}
\usepackage[utf8]{inputenc}
% Like in main document
\usepackage{mathptmx}
\usepackage{helvet}
\usepackage{courier}
\newcommand*{\Filename}{test.dat} % name of data file
\usepackage{pgfplots}
% Default options for plots
\pgfplotsset{%
compat=newest,
compat/show suggested version=false,
every axis/.append style={thick},
width=\paperwidth,
height=\paperheight,
%ymin=0,ymax=0.5,
%xmin=-4,xmax=4,
tick label style={font=\footnotesize},
label style={font=\footnotesize},
grid=both,
xlabel={}, ylabel={},
%y label style={at={(0.03,0.5)}},
legend style={
%at={(1,1)},
%anchor=north,
%legend columns=1,
%cells={anchor=west},
font=\footnotesize,
%rounded corners=1pt,
},
enlargelimits=false
}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot table[x index=0,y index=1] {\Filename};
\addplot table[x index=0,y index=2] {\Filename};
%\addplot table[x index=0,y index=3] {\Filename};
%\legend{1, 2}
\end{axis}
\end{tikzpicture}
\end{document}
具有\Filename
以下结构:
-4.15026086e+00 7.25473468e-05 1.41017490e-04
-3.86659676e+00 2.26169966e-04 1.05763117e-04
-3.58293265e+00 6.50582962e-04 5.99324332e-04
-3.29926855e+00 1.72673142e-03 1.55119239e-03
-3.01560444e+00 4.22864523e-03 4.44205093e-03
-2.73194034e+00 9.55503020e-03 1.00827505e-02
-2.44827623e+00 1.99212796e-02 2.09410973e-02
-2.16461213e+00 3.83227576e-02 3.75811611e-02
-1.88094802e+00 6.80221925e-02 6.63487290e-02
-1.59728392e+00 1.11403505e-01 1.17220789e-01
-1.31361981e+00 1.68345470e-01 1.65484024e-01
-1.02995571e+00 2.34724472e-01 2.39377189e-01
-7.46291604e-01 3.01974074e-01 2.99380131e-01
-4.62627499e-01 3.58455543e-01 3.52790505e-01
-1.78963394e-01 3.92604521e-01 3.91112008e-01
1.04700711e-01 3.96761612e-01 3.99960856e-01
3.88364816e-01 3.69963048e-01 3.68619719e-01
6.72028921e-01 3.18303494e-01 3.16725282e-01
9.55693026e-01 2.52684624e-01 2.53091140e-01
1.23935713e+00 1.85084726e-01 1.84944438e-01
1.52302124e+00 1.25088302e-01 1.24624207e-01
1.80668534e+00 7.80040529e-02 7.93575925e-02
2.09034945e+00 4.48819784e-02 4.54428861e-02
2.37401355e+00 2.38276477e-02 2.55241657e-02
2.65767766e+00 1.16719845e-02 1.14576711e-02
2.94134176e+00 5.27548738e-03 5.11188401e-03
3.22500587e+00 2.20006153e-03 1.86848174e-03
3.50866997e+00 8.46567166e-04 1.12813992e-03
3.79233408e+00 3.00567741e-04 2.82034980e-04
4.07599818e+00 9.84640435e-05 1.41017490e-04
答案1
和width
键height
无法正常工作。我参考了第 4.9 节“缩放选项”,第 199 页及后续页。PGF 手册, 和pgfplots:如何缩放到文本宽度?。
问题是,只有轴单位被缩放并且标签和描述高度/宽度仅被估计并且......
这是我的建议:
tikzscale
与 结合使用crop=false
。
TeX 认为生成的 TikZ 图片高于纸张高度,因此我手动减去0.001pt
,它适合一个站点。
代码
\documentclass[crop=false]{standalone}
\usepackage{geometry}
\geometry{%
paperwidth=52.65mm,
paperheight=47.75mm,
margin=0mm,
}
\newcommand*{\Filename}{101992} % name of data file
\begin{filecontents*}{\Filename.dat}
-4.15026086e+00 7.25473468e-05 1.41017490e-04
-3.86659676e+00 2.26169966e-04 1.05763117e-04
-3.58293265e+00 6.50582962e-04 5.99324332e-04
-3.29926855e+00 1.72673142e-03 1.55119239e-03
-3.01560444e+00 4.22864523e-03 4.44205093e-03
-2.73194034e+00 9.55503020e-03 1.00827505e-02
-2.44827623e+00 1.99212796e-02 2.09410973e-02
-2.16461213e+00 3.83227576e-02 3.75811611e-02
-1.88094802e+00 6.80221925e-02 6.63487290e-02
-1.59728392e+00 1.11403505e-01 1.17220789e-01
-1.31361981e+00 1.68345470e-01 1.65484024e-01
-1.02995571e+00 2.34724472e-01 2.39377189e-01
-7.46291604e-01 3.01974074e-01 2.99380131e-01
-4.62627499e-01 3.58455543e-01 3.52790505e-01
-1.78963394e-01 3.92604521e-01 3.91112008e-01
1.04700711e-01 3.96761612e-01 3.99960856e-01
3.88364816e-01 3.69963048e-01 3.68619719e-01
6.72028921e-01 3.18303494e-01 3.16725282e-01
9.55693026e-01 2.52684624e-01 2.53091140e-01
1.23935713e+00 1.85084726e-01 1.84944438e-01
1.52302124e+00 1.25088302e-01 1.24624207e-01
1.80668534e+00 7.80040529e-02 7.93575925e-02
2.09034945e+00 4.48819784e-02 4.54428861e-02
2.37401355e+00 2.38276477e-02 2.55241657e-02
2.65767766e+00 1.16719845e-02 1.14576711e-02
2.94134176e+00 5.27548738e-03 5.11188401e-03
3.22500587e+00 2.20006153e-03 1.86848174e-03
3.50866997e+00 8.46567166e-04 1.12813992e-03
3.79233408e+00 3.00567741e-04 2.82034980e-04
4.07599818e+00 9.84640435e-05 1.41017490e-04
\end{filecontents*}
\begin{filecontents*}{\Filename.tikz}
\begin{tikzpicture}
\begin{axis}
\addplot table[x index=0,y index=1] {\Filename.dat};
\addplot table[x index=0,y index=2] {\Filename.dat};
\legend{1, 2}
\end{axis}
\end{tikzpicture}
\end{filecontents*}
\usepackage{pgfplots,tikzscale}
\begin{document}\noindent
\includegraphics[height=\paperheight-.001pt,width=\paperwidth]{\Filename.tikz}%
\end{document}