matplotlib图例中文显示问题
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]:


还没有评论,来说两句吧...