setting figure font to helvetica

per freem <perfreem@...287...> writes:

i am trying to use the Helvetica font on matplotlib. i am using mac os x (so
i definitely have helvetica installed)

It might be in a format that matplotlib doesn't really handle. However,
Helvetica is one of the "core fonts" in PDF so if you set
pdf.use14corefonts to True, you should be able to use Helvetica, and the
reader application will supply the font (or approximate it with
something else). This is deprecated in the latest version of the spec,
but it should work just fine.

i verified that plt.rcParams gets modified to use 'Helvetica' as the value
for font.family, etc. but i still get the default font used in all of these
figures.

I just wanted to add: if i simply set the font to Arial, using

rc('font',**{'family':'sans-serif','sans-serif':['Arial']})

then it works. But the same call with Helvetica still defaults to that
Bitstream/default font of matplotlib. any idea why this might be? could
matplotlib be confusing helvetica with bitstream?

The font-selection system is somewhat complicated. I suggest running
your script with --verbose-debug with both Arial and Helvetica as the
value of font.sans-serif, and diffing the outputs to see what is going
on. I suspect that Arial is a TTF file while Helvetica is in some
Mac-specific format. The best solution would be to make matplotlib
handle those formats, but probably the most practical solution is to
use something like fondu to convert the font into TTF:
http://fondu.sourceforge.net/

···

--
Jouni K. Sepp�nen