1

Based on this question, I defined my own arrow style in TikZ and expected it to work in 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}

When using the myarrow style, I obtain the default arrowhead:

enter image description here

And when I do not use the myarrow style but instead define the arrowhead directly, I get:

enter image description here

What am I doing wrong?

user1362373
  • 2,859

1 Answers1

2

You should type \tikzset{myarrow/.style={-Computer Modern Rightarrow[round]}} instead of \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}

pgf plot custom arrow

SebGlav
  • 19,186
  • For posterity: SebGlav's answer solved my immediate problem, but it lead to another one, see https://tex.stackexchange.com/questions/585226/how-to-prevent-custom-arrow-tip-for-tikz-and-pgfplots-from-changing-arrow-direct. – user1362373 Feb 27 '21 at 20:58