简体   繁体   中英

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 . 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?

Try this:

import matplotlib 

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

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

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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