24

I am exporting charts from matplotlib and editing them in Illustrator. It's great that I can edit the lines, but the text also comes in as lines, so I cannot change fonts, edit text, etc. I've exported as EPS, PDF, and PS with the same issues.

I'm using matplotlib version 1.0.1 with python 2.7.1 on OSX Snow Leaopard.

I appreciate any insights offered! I tried using pdf2ps as suggested here, but all that did was degrade the quality of the image without making the text rendered as real text. pdftops looked nicer, but still can't edit the text results.

mishaF
  • 7,934
  • 9
  • 30
  • 34

1 Answers1

28

You can edit the text in Acrobat/Illustrator if you set pdf.fonttype to 42 (TrueType), and export in pdf. You can set this in your ~/matplotlib/matplotlibrc:

pdf.fonttype : 42 # Output Type 3 (Type3) or Type 42 (TrueType)

..or dynamically:

>>> import matplotlib as mpl
>>> mpl.rcParams['pdf.fonttype'] = 42

Apparently it defaults to Type3 which Acrobat/Illustrator can't deal with.

Zach Kelling
  • 52,505
  • 13
  • 109
  • 108
  • OCR in Acrobat did not work. I mean, it converted the the text while it was open in Acrobat, but after saving and opening in Illustrator, they are not editable as text still... – mishaF May 10 '11 at 21:11
  • Yes, Adobe seemingly cripples Illustator to force you to use Acrobat. Edit text it in Acrobat, or another PDF editor. – Zach Kelling May 10 '11 at 21:16
  • Actually, even using Acrobat, I can copy the text, but can't edit. It (Acrobat) tells me "all or part of the selection has no available system font..." – mishaF May 10 '11 at 21:21
  • actually acrobat derived from illustrator the native format for illustrator is pdf – mcgrailm May 10 '11 at 23:55
  • 2
    @mishaF I played with it today, apparently you can edit the text as long as you set pdf.fonttype to 42 – Zach Kelling May 11 '11 at 00:36
  • @zeekay That did it! Thanks so much for figuring that out! I tried the dynamic version of your answer and it worked great. – mishaF May 11 '11 at 14:14
  • This doesn't appear to work with `mpl.rcParams['text.usetex'] = True`. – Jan Jun 18 '13 at 12:49