matplotlib图例中文显示问题

来源:互联网 发布:centos shutdown命令 编辑:程序博客网 时间:2024/05/18 01:39

import numpy as np
import pandas as pd
from pandas import DataFrame,Series
import matplotlib
import matplotlib.pyplot as plt
import pylab as pl

#simkai.ttf 是电脑控制面板里字体的一种,这里是楷体
chinese =matplotlib.font_manager.FontProperties(fname='C:\Windows\Fonts\simkai.ttf')

x1 = [1, 2, 3, 4, 5]
y1 = [1, 4, 9, 16, 25]
x2 = [1, 2, 4, 6, 8]
y2 = [2, 4, 8, 12, 16]
plot1 = pl.plot(x1, y1, 'r',label=u'红')
plot2 = pl.plot(x2, y2, 'go',label=u'绿')
plt.legend(prop=chinese)

Out[31]: <matplotlib.legend.Legend at 0xe1ad390>


原创粉丝点击