TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have matplotlib figures with labels, which are included as PDF in LaTeX document. I would like label text match with the font of the text, which is concrete (via \usepackage{concrete}).

I can change math font in labels with

import matplotlib as mpl

but adding \usepackage{concrete} has no effect on the text font (probably since the default Helvetica is used regardless). usetex documentation does not mention concrete to be supported directly.

I also have the cm-unicode opentype variants of CMU fonts (CMU Concrete) installed, in case that could be of any use.

share|improve this question

migrated from stackoverflow.com Oct 24 '11 at 2:33

This question came from our site for professional and enthusiast programmers.

up vote 3 down vote accepted

This does not answer your question directly, but is perhaps a possible workaround:

As I mentioned in Set fonts in matplotlib graphs equal to tex document you can perhaps export your plot with the script matplotlib2tikz. This gives you a .tex file with a TikZ/pgfplots figure that can be input in your document. This will use the same fonts as the document.

Edit: For reference, here is a brief explanation of installation and use.

Having downloaded the files from github, navigate to the folder in a command line, and run python setup.py install to install matplotlib2tikz.

In your Python script add from matplotlib2tikz import matplotlib2tikz, and add matplotlib2tikz('filename.tex') after your plot, e.g.

from numpy import arange
from matplotlib2tikz import matplotlib2tikz
import matplotlib.pyplot as plt

x = arange(0,10,0.5)

plt.title("A lovely plot")

You can also specify the width and height of the plot in the Python script, as mentioned in the readme of matplotlib2tikz.

share|improve this answer
Very nice! In addition, it will work with any possible fonts. Thanks. – eudoxos Nov 2 '11 at 8:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.