11

Consider the following:

\documentclass{article}

\usepackage{tikz,pgfplots}

\usetikzlibrary{arrows.meta}
\tikzset{>={Latex[round]}}
\begin{document}
  \begin{tikzpicture}
    \begin{axis}[inner axis line style={>={Latex[round]},very thick,red},
                 axis lines=center]
       \addplot [->,>={Latex[round]}] coordinates {( 0,0)(1,1)};
    \end{axis}
  \end{tikzpicture}
\end{document}

Notice that the "very thick" and "red" style options are changed but the >={Latex[round]} one isn't. Is there another option just for arrow heads in axis lines ? I couldn't find any in the doc.

enter image description here

2 Answers 2

12

You can use

axis line style={-Latex[round]}

or (x axis line style, for example).

enter image description here

The code:

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{arrows.meta}

\begin{document}
  \begin{tikzpicture}
    \begin{axis}[inner axis line style={very thick,red},
                 axis lines=center,axis line style={-Latex[round]}]
       \addplot [->,>={}] coordinates {( 0,0)(1,1)};
    \end{axis}
  \end{tikzpicture}
\end{document}
4
  • I was 20sec too slow! Nice work Gonzalo. :-) Jan 13, 2015 at 16:31
  • Thanks, what's the difference between the >=Latex[] form that works in a \draw command and the -Latex[] one?
    – wilk
    Jan 13, 2015 at 17:41
  • @wilk The latter uses the <start arrow specification>-<end arrow specification> syntax. Jan 13, 2015 at 19:12
  • 1
    @wilk the difference is that >=Latex set the default arrow as Latex. So if we use later -> this will be equivalent to -Latex, but >=Latex will have no effect on -stealth. So if one style install -stealth, to overwrite it you have to set -Letex or >=Latex,-> after it.
    – Kpym
    Jan 13, 2015 at 20:29
8

Note that axis lines=center installs the following style

/pgfplots/every non boxed x axis/.style={%
  xtick align=center,
  enlarge x limits=false,
  x axis line style={-stealth}
},

So the order of the options is crucial. You have to change the axis lines firstly and the inner axis line style (or axis line style) secondly.

Additionally, the arrow tip is set to stealth explicitly. Therefore, it has no effect if the default arrow tip > is redefined by inner axis line style. You have to use -Latex[round] instead.

\documentclass{article}
\usepackage{pgfplots}

\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}
  \begin{axis}[
    axis lines=center,
    inner axis line style={-Latex[round],very thick,red}
  ]
     \addplot[] coordinates {( 0,0)(1,1)};
  \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

4
  • 2
    (+1) Good point for the order. But not only the order is crucial : as the arrow is set by -stealth and not by ->,>=stealth, it can't be overwritten with >={Latex[round]}, we have to use -{Latex[round]}.
    – Kpym
    Jan 13, 2015 at 20:23
  • @Kpym Thanks for the hint. I have added this in my answer.
    – esdd
    Jan 14, 2015 at 15:20
  • @esdd How can one achieve this result when rather using axis lines=left?
    – tush
    May 3, 2021 at 15:03
  • @tush With axis lines=left you have to change outer axis line style: outer axis line style={-Latex[round],very thick,red}
    – esdd
    May 4, 2021 at 7:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .