Mac OS X - Problem when saving figures in eps

Hi, First of all, I'd like to thank matplotlib developers

    > for providing us this wonderful library.

    > It's been a while now I'm using matplotlib and I'm pretty
    > happy with it. I used to be a Linux user. Recently, I
    > moved to Mac (a macbook pro, to be precise). I succeed to
    > install matplotlib. Everything is working correctly
    > except the export of figures into eps format (which is
    > important when writing papers with LaTeX).

    > When I'm trying to save a figure in eps, everything seems
    > ok. However, it is impossible to open the eps file. The
    > eps seems to be corrupted. A closer look at the eps file
    > shows that the generated file is 'heavy', i.e., several MB
    > (around 6MB on average). Note that other output formats
    > are correctly generated.

    > I don't really understand the source of the problem.
    > Probably something that is misconfigured. If somebody has
    > an idea on how to solve this problem, it would be great.

I am 99% sure this is a font problem. matplotlib embeds the truetype
font into the PS file, which accounts for most of the file size. Paul
Barrett at one point looked into just embedding he glyphs we use
rather than the entire font file but was unsuccessful. It would be
nice if some font guru could revisit this issue at some point since it
would be a big win in terms of file size. What appears to be
happening is that mpl is finding and using a native os x font rather
than the Vera fonts that mpl ships with.

Try editing your matplotlib rc file and change these font preferences

  font.serif : New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Bitstream Vera Serif, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif
  font.sans-serif : Lucida Grande, Verdana, Geneva, Lucida, Bitstream Vera Sans, Arial, Helvetica, Avant Garde, sans-serif
  font.cursive : Apple Chancery, Textile, Zapf Chancery, Sand, cursive
  font.fantasy : Comic Sans MS, Chicago, Charcoal, Impact, Western, fantasy
  font.monospace : Andale Mono, Bitstream Vera Sans Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace

by moving the bitstream fonts to the front.

I'm inclined to make the bitstream fonts the default (the first item
in the default rc list) so that others won't be bitten by this until
we solve the "dump the entire font" problem. Any objections?

Benoit, please let us know if this fixes your problem. After changing
the rc file, please recursively remove ~/.matplotlib/ttffont.cache
before rerunning. Also, if you run your script with --verbose-debug
you will get information about which fonts are loaded.

JDH

Hello John

I am 99% sure this is a font problem. matplotlib embeds the truetype

Nice intuition. I didn't think about any font problem. I was expecting some configuration problem

  font.serif : New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Bitstream Vera Serif, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif
  font.sans-serif : Lucida Grande, Verdana, Geneva, Lucida, Bitstream Vera Sans, Arial, Helvetica, Avant Garde, sans-serif
  font.cursive : Apple Chancery, Textile, Zapf Chancery, Sand, cursive
  font.fantasy : Comic Sans MS, Chicago, Charcoal, Impact, Western, fantasy
  font.monospace : Andale Mono, Bitstream Vera Sans Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace

by moving the bitstream fonts to the front.

I moved the bitstream fonts to the front.

I'm inclined to make the bitstream fonts the default (the first item
in the default rc list) so that others won't be bitten by this until
we solve the "dump the entire font" problem. Any objections?

Benoit, please let us know if this fixes your problem.

It is working now.

Eps files are correctly generated and the resulting files have 'normal' sizes (below 100K).

Thank you very much for the help! I really appreciate.

Benoit

After changing

···

the rc file, please recursively remove ~/.matplotlib/ttffont.cache
before rerunning. Also, if you run your script with --verbose-debug
you will get information about which fonts are loaded.

JDH

--
Benoit Donnet
Université Pierre & Marie Curie (Paris VI)
Laboratoire LIP6 - Réseaux & Performances
8, rue du Capitaine Scott
75015 Paris
France
Phone: 00 33 (0)1 44 27 88 83
traceroute@...210... Project: http://trhome.sourceforge.net
Home Page: http://rp.lip6.fr/~donnet

BTW, I have to use TeX with mpl otherwise it does not work.

rc('text', usetex=True)

Benoit

Benoit Donnet a écrit :

···

Hello John

I am 99% sure this is a font problem. matplotlib embeds the truetype

Nice intuition. I didn't think about any font problem. I was expecting some configuration problem

  font.serif : New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Bitstream Vera Serif, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif
  font.sans-serif : Lucida Grande, Verdana, Geneva, Lucida, Bitstream Vera Sans, Arial, Helvetica, Avant Garde, sans-serif
  font.cursive : Apple Chancery, Textile, Zapf Chancery, Sand, cursive
  font.fantasy : Comic Sans MS, Chicago, Charcoal, Impact, Western, fantasy
  font.monospace : Andale Mono, Bitstream Vera Sans Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace

by moving the bitstream fonts to the front.

I moved the bitstream fonts to the front.

I'm inclined to make the bitstream fonts the default (the first item
in the default rc list) so that others won't be bitten by this until
we solve the "dump the entire font" problem. Any objections?

Benoit, please let us know if this fixes your problem.

It is working now.

Eps files are correctly generated and the resulting files have 'normal' sizes (below 100K).

Thank you very much for the help! I really appreciate.

Benoit

After changing

the rc file, please recursively remove ~/.matplotlib/ttffont.cache
before rerunning. Also, if you run your script with --verbose-debug
you will get information about which fonts are loaded.

JDH

--
Benoit Donnet
Université Pierre & Marie Curie (Paris VI)
Laboratoire LIP6 - Réseaux & Performances
8, rue du Capitaine Scott
75015 Paris
France
Phone: 00 33 (0)1 44 27 88 83
traceroute@...210... Project: http://trhome.sourceforge.net
Home Page: http://rp.lip6.fr/~donnet