Edit Matplotlib Exported PDF File in Illustrator

In academic paper writing, it’s a common situation that we need to make some annotations to our Matplotlib plots. This blog gives a perfect solution to edit those plots while keep them in editable/searchable state.

If those plots are exported by Matplotlib in .pdf or .ps formats, you’ll find Illustrator can not recognize those editable texts. As a consequence, readers can not search the text in your plots or select them. It’s quite not elegant.

The main problem is that Matplotlib will render your .pdf file with type 3 font type, which is unrecognizable in Adobe Illustrator. You can change the render manually to TrueType, which is recognizable in Illustrator.

from matplotlib import rcParams
rcParams['pdf.fonttype']=42

# Your image drawing
plt.savefig("title.pdf")

Surprisingly all the things done. The exported title.pdf will work perfectly in Illustrator. Now you can play with texts all as you want!

One more thing: the exported .pdf will be extreme large (in my case, type 3 as 10kB while TrueType as 300kB). But it’s ok, after editing in Illustrator, you can choose a compressing rendering scheme when saving.

Leave a comment