2

I want to produce a plot with matplotlib and use the command

plt.rc('text', usetex=True)

to render the text with LaTeX. I output the file with plt.savefig as a pdf. When I include the above command, I get a nice TeX font but the file size increases by a factor 20 or more, depending on the amount of text in the plot (compared to the output of the same script with plt.rc('text', usetex=True) commented out).

Is there any way to have TeX rendering without increasing the file size?

Kristian Barrett
  • 3,574
  • 2
  • 26
  • 40
Lukas S
  • 21
  • 1
  • Probably not. But did you check if this is really a factor of 20 and not maybe just 100kb more? – ImportanceOfBeingErnest Jul 10 '19 at 16:50
  • 1
    Yeah, I think this is just a constant offset of some 100kb or so, which is caused by the fact that latex fonts are in general larger than the default TrueType fonts. Also, if different font sizes are used, more latex fonts need to be embedded, while a single TrueType font can cover all font sizes. – ImportanceOfBeingErnest Jul 10 '19 at 17:03
  • Does this answer your question? [Reducing file sizes of PDFs created using matplotlib by changing font embedding](https://stackoverflow.com/questions/60076026/reducing-file-sizes-of-pdfs-created-using-matplotlib-by-changing-font-embedding) – olegrog Dec 18 '20 at 23:49

0 Answers0