迷糊妖

永不停止追寻前进的脚步
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

python - 图例显示中文

Posted on 2015-12-03 18:04  迷糊妖  阅读(2120)  评论(0编辑  收藏  举报
# -*- 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=r'D:\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()