Como posso obter a mesma fonte nos tiques e no rótulo do pgfplot?

Como posso obter a mesma fonte nos tiques e no rótulo do pgfplot?

Tento alcançar a mesma fonte em todos os lugares possíveis dentro do gráfico pgf. Depois de muitas horas neste fórum e testes de soluções escritas, não tenho ideia.

Muito obrigado pela ajuda antecipadamente.

Atenciosamente, Th.

\documentclass{scrartcl}

\usepackage{fontspec}
\setmainfont{Arial}

\usepackage{etoolbox}
% change fonts to sans serif then `tikzpicture' environment is started
\BeforeBeginEnvironment{tikzpicture}{
    \begingroup
        \changeFonts
}
% end scope (for font change)
\AfterEndEnvironment{tikzpicture}{
    \endgroup
}
\usepackage{sansmath}
% create a command to switch fonts in `tikzpicture' environments to a
% sans serif font
\newcommand*\changeFonts{
   \sffamily\sansmath
}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

10 <> $\mathsf 10$!

\begin{figure}[htbp]
\centering
\begin{tikzpicture}
\begin{axis}[xlabel={Abscissa, $x_\mathsf{10}$}, ylabel={Ordinate, $y$}]
\addplot {x^2};
\end{axis}
\end{tikzpicture}
\caption{A figure with a \texttt{pgfplots} axis.}
\end{figure}

\end{document}

Responder1

Você pode alterar a fonte do rótulo de todos os ticks para sansserif com

\pgfplotsset{my style/.append style={xticklabel={$\mathsf{\pgfmathprintnumber{\tick}}$},

 yticklabel={$\mathsf{\pgfmathprintnumber{\tick}}$} } }

E então adicionando my styleàs opções do eixo:

begin{axis}[my style, xlabel={Abscissa, $x_\mathsf{10}$}, ylabel={Ordinate, $y$}]

informação relacionada