解决sea_born和matplotlib画图中文显示的问题

#以下解决mtpl中文显示问题
from pylab import *
mpl.rcParams['font.sans-serif'] = ['SimHei']


#以下解决seaborn中文编码报错问题
import sys
reload(sys)
sys.setdefaultencoding('utf8') 
sns.set_context("talk")



  

###测试


df_test=pd.DataFrame({'分类':['分类1','分类2','分类3','分类4','分类1'],'长度':[19,20,30,40,129],'width':[2,3,4,5,12],'height':[233,231,321,346,133]})
# print df_test

 

df_test['height']= (df_test['height']-df_test['height'].min(axis=0))/(df_test['height'].max(axis=0)-df_test['height'].min(axis=0))
df_test['长度']= (df_test['长度']-df_test['长度'].min(axis=0))/(df_test['长度'].max(axis=0)-df_test['长度'].min(axis=0))
df_test['width']= (df_test['width']-df_test['width'].min(axis=0))/(df_test['width'].max(axis=0)-df_test['width'].min(axis=0))
# df_test['height']= (df_test['height']-df_test['height'].min(axis=0))/(df_test['height'].max(axis=0)-df_test['height'].min(axis=0))
print df_test

andrews_curves(df_test, '分类')
plt.show()
sns.pairplot(df_test,hue='分类')
plt.show()

  

posted @ 2016-11-24 22:20  迈克儿  阅读(730)  评论(0编辑  收藏  举报