2

I have a document with a custom font montserrat. I also have the following plot:

\documentclass[a4paper]{standalone}

\usepackage[extralight,defaultfam,light,tabular,lining]{montserrat} % Font

% For bar chart \usepackage{pgfplots}

\begin{document} \begin{tikzpicture} \begin{axis}[ ymajorgrids=true, scale only axis, xtick={1,2,3,4,5}, xticklabels={Foo,Bar,Baz,FooBar,FooBaz}, every axis plot/.append style={ ybar, bar width=20, bar shift=0pt, fill }, ymin=0, ] \addplot[purple] coordinates {(1,1)}; \addplot[red] coordinates {(2,2)}; \addplot[yellow] coordinates {(3,3)}; \addplot[gray] coordinates {(4,6)}; \addplot[blue] coordinates {(5,2)}; \end{axis} \end{tikzpicture} \end{document}

Unfortunately, only the x axis seems to adapt to the montserrat font, i.e., the y axis still has the default latex font. How can I get the y axis to be displayed in the montserrat font as well?

Text

Qrrbrbirlbel
  • 119,821
twit
  • 53

2 Answers2

2

Tell pgfplots that the tick labels should be text in \normalfont.

\documentclass[a4paper,border=2]{standalone}

\usepackage[extralight,defaultfam,light,tabular,lining]{montserrat} % Font

% For bar chart \usepackage{pgfplots}

\begin{document} \begin{tikzpicture} \begin{axis}[ ymajorgrids=true, scale only axis, tick label style={font=\normalfont}, xtick={1,2,3,4,5}, xticklabels={Foo,Bar,Baz,FooBar,FooBaz}, ytick={0,1,2,3,4,5,6}, yticklabels={0,1,2,3,4,5,6}, every axis plot/.append style={ ybar, bar width=20, bar shift=0pt, fill }, ymin=0, ] \addplot[purple] coordinates {(1,1)}; \addplot[red] coordinates {(2,2)}; \addplot[yellow] coordinates {(3,3)}; \addplot[gray] coordinates {(4,6)}; \addplot[blue] coordinates {(5,2)}; \end{axis} \end{tikzpicture} \end{document}

enter image description here

egreg
  • 1,121,712
0

Credit to Henri Menke user.

\documentclass[a4paper]{standalone}

\usepackage[extralight,defaultfam,light,tabular,lining]{montserrat} % Font \usepackage[italic]{mathastext} % For bar chart \usepackage{pgfplots}

\begin{document} \begin{tikzpicture} \begin{axis}[ ymajorgrids=true, scale only axis, xtick={1,2,3,4,5}, xticklabels={Foo,Bar,Baz,FooBar,FooBaz}, every axis plot/.append style={ ybar, bar width=20, bar shift=0pt, fill }, ymin=0, ] \addplot[purple] coordinates {(1,1)}; \addplot[red] coordinates {(2,2)}; \addplot[yellow] coordinates {(3,3)}; \addplot[gray] coordinates {(4,6)}; \addplot[blue] coordinates {(5,2)}; \end{axis} \end{tikzpicture} \end{document}

enter image description here

Sebastiano
  • 54,118