Python | Mac下matplotlib中文显示乱码

解决matplotlib中文显示乱码找到一个简单的方法

对Mac来说,一部分字体放在了这里:/Library/Fonts/

还有一部分在这里:/System/Library/Fonts/

在使用的时候直接指定字体就好了:

# coding=utf-8
from matplotlib.font_manager import FontProperties
font = FontProperties(fname='/Library/Fonts/Songti.ttc')

from matplotlib import pyplot as plt
plt.title(u'显示中文', FontProperties=font)
plt.show()

发布了342 篇原创文章 · 获赞 794 · 访问量 178万+

猜你喜欢

转载自blog.csdn.net/u014365862/article/details/104469335