
我不知道如何将轴线样式从“带箭头”(在样式中设置)覆盖为“不带箭头”。
以下是 MWE:
\documentclass[]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots,tikz}
\pgfplotsset{compat=newest}
\pgfplotsset{
axisStyle/.style={axis y line =left,
axis x line =bottom,
axis line style ={very thick}}
}
\begin{document}
\begin{figure}[htbc]
\centering
\begin{tikzpicture}
\begin{axis}
[ axisStyle,
axis y line=none,
axis y line*=left,
axis x line*=bottom,
ymax=5
]
\addplot[domain=-2:2] {x^2};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
如您所见,简单地将线条样式设置为“无箭头”是行不通的,首先将其设置为无也无济于事。
注意:实际上我的风格当然包含更多选项,因此使用该风格并仅更改这两个设置(如果可能)仍然是合理的。
答案1
要修改轴线的样式,请使用<axis> axis line style={<styles>}
,其中<axis>
是需要修改的轴(x
,,,或省略以设置所有轴y
的z
样式),<styles>
是需要应用的样式。
因此,我们可以axis line style={-}
在axis
选项中使用 来覆盖 ,axisStyle
并在本地设置轴线无箭头。这里我省略了 ,<axis>
因为只绘制了一条轴线,但效果与 相同x axis line style
。
这些钥匙将是附加到当前安装的轴线样式,这就是为什么axis line style ={very thick}
fromaxisStyle
仍然有效。
\documentclass[tikz]{standalone}
\usepackage{pgfplots,tikz}
\pgfplotsset{compat=1.12}
\pgfplotsset{
axisStyle/.style={
axis y line =left,
axis x line =bottom,
axis line style ={very thick},
}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axisStyle,
axis line style={-},
axis y line=none,
ymax=5,
]
\addplot[domain=-2:2] {x^2};
\end{axis}
\end{tikzpicture}
\end{document}