3

Is it possible to change the arrowhead in a label?

In combination with the draw command it is easy to modify arrowheads:

\documentclass[a4paper, 12pt]{book}
\usepackage{fontspec}                   
\setmainfont{Cambria}                   
\setsansfont{Calibri}                   
\newfontfamily\Headerfamily{Calibri}    

\usepackage[ngerman]{babel}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{calc,fadings,decorations.pathreplacing,arrows.meta}
\usepackage{mathtools}

\tikzset{>=latex, % option for nice arrows
  inner sep=0pt,%
  outer sep=2pt,%
  mark coordinate/.style={inner sep=0pt,outer sep=0pt,minimum size=3pt,
    fill=black,circle}%
}

\begin{document}

    \begin{tikzpicture}
        \draw[->] (0,0) -- (1,0);   
    \end{tikzpicture}

\end{document}

I would prefer an arrow head at the xlabel and ylabel like in the example above instead of \rightarrow like in the example below:

\documentclass[a4paper, 12pt]{book}
\usepackage{fontspec}                   
\setmainfont{Cambria}                   
\setsansfont{Calibri}                   
\newfontfamily\Headerfamily{Calibri}    

\usepackage[ngerman]{babel}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{calc,fadings,decorations.pathreplacing,arrows.meta}
\usepackage{mathtools}

\begin{document}

            \begin{tikzpicture}
                \begin{axis}[domain=0:45,
                        /pgf/number format/1000 sep={},
                        samples=180,
                        grid=major,smooth,
                        xmin=0,
                        xmax=45,
                        ymin=-0.5,
                        ymax=0.5,
                        xlabel=$ ^{\circ} C \rightarrow$,
                        ylabel=$ m s^{\, -2} \rightarrow$, 
                        legend pos=north west],
                        \legend{$Temperature drift$}
                    \addplot [color=black,thick]  
                        {(-0.000003643682714*x^3+
                        (0.000234812441401*x^2+
                        (0.004932909568573*x};
                \end{axis}
            \end{tikzpicture}
\end{document}

Is there any way to modify the head of \rightarrow that it looks like the arrowhead in the first example?

Current legend: Legend with \rightarrow

Preferred legend: Legend with prefered arrow

  • 1
    Welcome to TeX.SX!! Rather than posting code fragments it is better to give a full minimal working example. Currently we have to guess what packages etc you are using and this makes it really hard to help you. A MWE should start with a \documentclass command, have a minimal preamble and then \begin{document}...\end{document}. The code should compile and be as small as possible to demonstrate your problem. – user30471 Aug 5 '18 at 13:14
3

something like this:

enter image description here

\documentclass[a4paper, 12pt]{book}
\usepackage{fontspec}
\setmainfont{Cambria}
\setsansfont{Calibri}
\newfontfamily\Headerfamily{Calibri}

\usepackage[ngerman]{babel}
\usepackage{graphicx}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
% \usetikzlibrary{arrows.meta, calc, fadings, decorations.pathreplacing} % not needed
\usepackage{mathtools}
\usepackage{siunitx}     % new, for units

\newcommand\arr{\tikz[baseline=-0.6ex]\draw[-latex] (0,0) -- + (7mm,0);} % <--- define arrow for your axis labels

\begin{document}
    \begin{tikzpicture}
\begin{axis}[domain=0:45,
    /pgf/number format/use comma,
    samples=180,
    grid=major,smooth,
    xmin=0,
    xmax=45,
    ymin=-0.5,
    ymax=0.5,
    xlabel={\si{\celsius} \arr},                 % <---
    ylabel={\si{\meter\per\square\second} \arr}, % <---
    legend pos=north west
            ]
    \legend{\emph{Temperature drift}}  % <--- changed
\addplot [color=black,thick]
    {(-0.000003643682714*x^3+
     (0.000234812441401*x^2+
     (0.004932909568573*x};
\end{axis}
    \end{tikzpicture}
\end{document}

edit (1): to have decimal comma instead dot you need to replace /pgf/number format/1000 sep={}, (which is actually not needed in your case) with /pgf/number format/use comma, (now consider in above mwe).

edit (2): to set decimal commas globally you is only need to move /pgf/number format/use comma, to \pgfplotsset (where you can collect all common options of yours pgfplots images):

\usepackage{pgfplots}
\pgfplotsset{compat=1.16,
            /pgf/number format/use comma,   % <---
            }

and than for image write:

    \begin{tikzpicture}
\begin{axis}[domain=0:45,
    samples=180,
    grid=major, smooth,
    xmin=0,
    xmax=45,
    ymin=-0.5,
    ymax=0.5,
    xlabel={\si{\celsius} \arr},                 % <---
    ylabel={\si{\meter\per\square\second} \arr}, % <---
    legend pos=north west
            ]
    \legend{\emph{Temperature drift}}  % <--- changed
\addplot [color=black,thick]
    {(-0.000003643682714*x^3+
     (0.000234812441401*x^2+
     (0.004932909568573*x};
\end{axis}
    \end{tikzpicture}
\end{document}
  • 1
    I've read through a lot of sites and the answer is that simple :) Thank you very much! – Arrow Aug 5 '18 at 16:47
  • 1
    How would I have to modify the code to have ", " instead of " . " as numeric separator on the axis? – Arrow Aug 6 '18 at 17:44
  • 1
    a decimal comma instead dot? i will look in pgfplots manual :-) – Zarko Aug 6 '18 at 17:49
  • 2
    see edit of the answer. – Zarko Aug 6 '18 at 18:00
  • 2
    @Arrow, of course it is possible. see edit (2) in my answer. – Zarko Aug 11 '18 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.