ax.scatter中的label中文乱码

Posted 时光-ing

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ax.scatter中的label中文乱码相关的知识,希望对你有一定的参考价值。

问题: label标签的中文无法显示。

解决办法:
引入下面一段代码即可:

import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
font_set = FontProperties(fname=r"c:\\windows\\fonts\\simsun.ttc", size=15)
plt.rcParams['font.sans-serif'] = ['Microsoft YaHei']  # 引入后,可以正常使用中文字体
......

问题解决后的图例:

以上是关于ax.scatter中的label中文乱码的主要内容,如果未能解决你的问题,请参考以下文章