修改标签中的箭头

修改标签中的箭头

可以更改标签中的箭头吗?

结合绘制命令可以轻松修改箭头:

\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}

我更喜欢在 xlabel 和 ylabel 上使用箭头,如上例所示,而不是像下例所示使用 \rightarrow :

\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}

有什么方法可以修改 \rightarrow 的头部,使其看起来像第一个例子中的箭头?

現代圖例: 带 \rightarrow 的图例

首选图例: 带有首选箭头的图例

答案1

像这样:

在此处输入图片描述

\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}

编辑(1): 要使用小数点逗号而不是点,您需要将/pgf/number format/1000 sep={},(在您的情况下实际上不需要)替换为/pgf/number format/use comma,(现在考虑上面的 mwe)。

编辑(2): 要全局设置小数逗号,您只需移动/pgf/number format/use comma,\pgfplotsset(您可以在其中收集图像的所有常用选项pgfplots):

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

然后对于图像写入:

    \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}

相关内容