简体   繁体   English

如何在 matplotlib plot 中获得与 latex 相同的字体?

[英]How to get same font in matplotlib plot as latex?

I want the font in my python plot to be consistent with the latex. I found another answer .我希望我的python plot中的字体和latex中的字体保持一致。我找到了另一个答案 But it doesn't work on my computer and the error is但它在我的电脑上不起作用,错误是

KeyError: 'text.latex.unicode is not a valid rc parameter (see rcParams.keys() for a list of valid parameters)'

Can anyone provide me a method that can be used for current version of python?谁能给我提供一种可用于当前版本 python 的方法?

Try this:尝试这个:

import matplotlib 

font = {'family' : 'serif',
         'size'   : 12,
         'serif':  'cmr10'
         }

matplotlib.rc('font', **font)

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM