# Change font family in pgfplots (followup)

The MWE below shows that the solution at How can I change the font family in pgfplots? does not cover all the cases. The digits in the plot itself and the subscript in math mode in the title need further attention.

\documentclass{standalone}
\usepackage{tikz,pgfplots}
\usepackage{pgfplotstable}

%deal with warning message in log
\pgfplotsset{compat=1.8}

\usepackage{helvet}
\usepackage[eulergreek]{sansmath}
\pgfplotsset{
tick label style = {font=\sansmath\sffamily},
every axis label = {font=\sansmath\sffamily},
legend style = {font=\sansmath\sffamily},
label style = {font=\sansmath\sffamily}
}

name, footprint
}\carbonfootprints

\begin{document}
\begin{tikzpicture}[font=\sffamily]

\begin{axis}[
xbar, xmin=0,
tick style={draw=none},
width=8cm, height=3cm,
title={Estimated carbon footprint, g CO${}_2$},
enlarge y limits=0.3,
ytick=data,
yticklabel style={align=right},
yticklabels={
},
nodes near coords,
nodes near coords align={horizontal},
]
\addplot [fill=red] table [x=footprint, y expr=\coordindex]
{\carbonfootprints};
\end{axis}
\end{tikzpicture}
\end{document}


If you add font=\sffamily\sansmath to the tikzpicture options (or the axis options), all text will be in sans serif, without you having to find all relevant styles:

\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

%deal with warning message in log
\pgfplotsset{compat=1.8}

\usepackage{helvet}
\usepackage[eulergreek]{sansmath}

name, footprint
}\carbonfootprints

\begin{document}
\begin{tikzpicture}[font=\sffamily\sansmath]

\begin{axis}[
xbar, xmin=0,
tick style={draw=none},
width=8cm, height=3cm,
title={Estimated carbon footprint, g CO${}_2$},
enlarge y limits=0.3,
ytick=data,
yticklabel style={align=right},
yticklabels={

• You solved a problem of mine: Making Tikz Graphics with serif fonts for the report, and making them with sans-serif fonts as standalone image for presentations. Including the sansmath and \tikzset{every picture/.style={font=\sffamily\sansmath}} into the preamble of the standalone tex file did the trick without the need of changing the original tikz code for the image. – Dohn Joe Jan 25 '16 at 8:45
• Same here. Including [font=\sffamily\sansmath] in the tikzpicture-options made the\pgfplotsset-definitions regarding sans-serif usage (axis and tick labels, legend) superfluous. Additionally, it solved the problem of displaying an additional node text in sans-serif font (which the pgfplotsset, in my case, did not). – pogo-otter Sep 13 '16 at 6:57