基于这个问题,我定义了自己的箭头样式TikZ
并期望它可以在pgfplots
:
\documentclass{standalone}
\usepackage{pgfplots}
\usetikzlibrary{arrows.meta}
\pgfplotsset{compat=newest}
\tikzset{myarrow/.style={>={Computer Modern Rightarrow[round]}}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines = middle,
%axis line style={-Computer Modern Rightarrow[round]}, % works
axis line style={myarrow} % does not work
]
\addplot {x^2};
\end{axis}
\end{tikzpicture}
\end{document}
使用该myarrow
样式时,我获得了默认箭头:
当我不使用 myarrow 样式而是直接定义箭头时,我得到:
我究竟做错了什么?
答案1
您应该输入\tikzset{myarrow/.style={-Computer Modern Rightarrow[round]}}
而不是\tikzset{myarrow/.style={>={Computer Modern Rightarrow[round]}}}
。
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{arrows.meta}
\pgfplotsset{compat=newest}
\tikzset{myarrow/.style={-Computer Modern Rightarrow[round]}} %<--- edit
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines = middle,
axis line style={myarrow} % does work now
]
\addplot {x^2};
\end{axis}
\end{tikzpicture}
\end{document}