How can I change the font family in pgfplots?
Simply using \pgfplotsset
and \sffamily
is probably not sufficient for you, since your numbers and labels are in math mode. It can be achieved with the sansmath
package, such as
\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}
}
You probably have still to take care of Greek letters though, if you use eulervm
. Without that package, \sansmath
works well. Or, omit sans serif style for the label, and do it manually at this specific place, such as
xlabel = {$\mathsf{x}$},
ylabel = {$\phi\mathsf{(x)}$},
All together I got with your code all labels in sans serif, while the caption remains in serif font:
This is more of an extended comment than an answer, but I think it might be useful for others.
Following page 75 of the pgfplots
manual (Revision 1.17 (2020/02/29))
\pgfplotsset{
xticklabel={$\mathsf{\pgfmathprintnumber{\tick}}$},
yticklabel={$\mathsf{\pgfmathprintnumber{\tick}}$},
}