python - 图例显示中文

时间:2015-12-03 19:13:24   收藏:0   阅读:504
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 30 13:24:00 2015

@author: jx_luo
"""

from pandas import DataFrame, Series

import pandas as pd
import numpy as np

import matplotlib.pyplot as plt
import matplotlib.font_manager as font_manager

path=rD:\Users\jx_luo\Documents\wait.txt
frame=pd.read_csv(path,header=False,sep=\t)



f=pd.pivot_table(frame, index=createdate,values=wait,columns=paycategory ,aggfunc=np.sum)


#ax = f.plot(subplots=True,figsize=(12,20),grid=False, title=‘wait ‘)

ax=f.plot()

legend = ax.legend()
font = font_manager.FontProperties(fname=r"C:\Windows\Fonts\simhei.ttf")

for text in legend.texts:
    text.set_font_properties(font)

plt.show()

 

原文:http://www.cnblogs.com/melodyluo/p/5017117.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!