Usetex 字体效果

此脚本演示了pdf usetex现在支持pdftex.map中指定的字体效果。

Usetex 字体效果示例

  1. import matplotlib
  2. import matplotlib.pyplot as plt
  3. matplotlib.rc('text', usetex=True)
  4. def setfont(font):
  5. return r'\font\a %s at 14pt\a ' % font
  6. for y, font, text in zip(range(5),
  7. ['ptmr8r', 'ptmri8r', 'ptmro8r',
  8. 'ptmr8rn', 'ptmrr8re'],
  9. ['Nimbus Roman No9 L ' + x for x in
  10. ['', 'Italics (real italics for comparison)',
  11. '(slanted)', '(condensed)', '(extended)']]):
  12. plt.text(0, y, setfont(font) + text)
  13. plt.ylim(-1, 5)
  14. plt.xlim(-0.2, 0.6)
  15. plt.setp(plt.gca(), frame_on=False, xticks=(), yticks=())
  16. plt.title('Usetex font effects')
  17. plt.savefig('usetex_fonteffects.pdf')

脚本的总运行时间:(0分1.262秒)

下载这个示例