我希望enlargelimits
所有 pgfplots 中的设置都相同,将箭头与刻度线分开。因此我想将其添加到\pgfplotsset
preable 中。我应该把它放在哪里?
\documentclass{minimal}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{
compat=1.17,
% enlargelimits={value=0.1,upper}, %%% does not work
every axis/.style={
% enlargelimits={value=0.1,upper}, %%% does not work
axis line style={-stealth},
axis lines={center},
scaled ticks=base 10:3,
every x tick scale label/.style={
at=(current axis.right of origin),
right,
},
every y tick scale label/.style={
at=(current axis.north west),
above,
},
},
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
enlargelimits={value=0.1,upper}, %%% works just fine
xtick scale label code/.code={$x \cdot 10^{#1}$},
ytick scale label code/.code={$y \cdot 10^{#1}$},
]
\addplot table {
1e-3 1e-3
3e-3 3e-3
};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
嗯,对选项顺序进行一些小改动(参见下面的 MWE)并使用最近的pgfplots
(v 1.18)后,它对我有用:
\documentclass[border=3.141592]{standalone}
\usepackage{pgfplots}
\pgfplotsset{
compat=1.18,
axis line style = {-stealth},
axis lines = {center},
enlargelimits = {value=0.1,upper}, % <---now it works
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xtick scale label code/.code={$x \cdot 10^{#1}$},
ytick scale label code/.code={$y \cdot 10^{#1}$},
]
\addplot table {
1e-3 1e-3
3e-3 3e-3
};
\end{axis}
\end{tikzpicture}
\end{document}