从tikzscale
文档中我了解到,它应该保持字体大小不变。但是,这似乎不适用于pgfplots
'axis
环境中的轴刻度或轴标签。此外,节点放置似乎很混乱。以下示例说明了这一点:
\documentclass[10pt,crop]{standalone}
\usepackage[english]{babel}
\usepackage{pgfplots}
\usepackage{tikzscale}
\usepackage{filecontents}
\pgfplotsset{compat=1.9}
\begin{document}
\begin{filecontents}{font-size.tikz}
\begin{tikzpicture}
\begin{axis}[
width=150pt,
height=150pt,
xmin=-1,xmax=1,ymin=-1,ymax=1,
xlabel=xlabel,
ylabel=ylabel,
]
\addplot coordinates{
(-0.9,-0.9)
(0.9,0.9)
};
\node[anchor=west] at (axis cs:-1,0) {01};
\coordinate (a) at (axis cs:-1,0);
\end{axis}
\node[anchor=west,red] at (a) {02};
\end{tikzpicture}
\end{filecontents}
Some text in font size 10pt.
\input{font-size.tikz}
\includegraphics[width=250pt]{font-size.tikz}
\end{document}
在没有 的情况下创建的第一个图中tikzscale
,所有标签和节点都具有正确的字体大小,并且节点“02”的位置正确。然而,在第二个图中,标签的字体大小显然更大。节点“01”也是如此。有趣的是,节点“02”具有正确的字体大小,但位置错误。有没有办法正确缩放axis
(或groupplot
)环境,同时保留标签和节点的字体大小并将节点放置在正确的位置?
答案1
不指定
width=150pt,
height=150pt,
axisratio
到选项中的轴。这没有意义,因为您是从外部控制尺寸。此外,如果您想要不同的轴比,还会提供键。
\documentclass[10pt,crop]{standalone}
\usepackage[english]{babel}
\usepackage{pgfplots}
\usepackage{tikzscale}
\usepackage{filecontents}
\pgfplotsset{compat=1.9}
\begin{document}
\begin{filecontents}{font-size.tikz}
\begin{tikzpicture}[transform shape]
\begin{axis}[
% width=150pt, %% don't give this
% height=150pt, %% don't give this
xmin=-1,xmax=1,ymin=-1,ymax=1,
xlabel=xlabel,
ylabel=ylabel,
]
\addplot coordinates{
(-0.9,-0.9)
(0.9,0.9)
};
\node[anchor=west] at (axis cs:-1,0) {01};
\coordinate (a) at (axis cs:-1,0);
\end{axis}
\node[anchor=west,red] at (a) {02};
\end{tikzpicture}
\end{filecontents}
Some text in font size 10pt.
\input{font-size.tikz}
\includegraphics[width=250pt]{font-size.tikz} %% use width=250pt,axisratio=2 to see the change
\end{document}