plot.pie画餅状図/色の設定/中国語表示の設定
4411 ワード
import pandas as pd
df1 = pd.read_csv('/home/sc/Desktop/2018-5-21/2018-7-18/contract_company_predict_03.csv')
# df2 = df1.groupby('shixin_risk_rank_actual').size()
df2 = df1.groupby('bankrupt_risk_rank').size()
print(df2)
import numpy as np
from pylab import *
mpl.rcParams['font.sans-serif'] = ['Fangsong']
mpl.rcParams['axes.unicode_minus'] = False
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
import numpy as np
'''
fc-list :lang=zh
'''
chinese_font_path = FontProperties(fname = '/usr/share/fonts/truetype/arphic/uming.ttc')
from matplotlib.font_manager import FontProperties
import matplotlib.pyplot as plt
plt.figure(figsize=(6,9))
# labels = u' ', u' ', u' ', u' ',u' '
labels = u' ', u' ', u' ', u' ',u' '
colors = ['lightskyblue','green','red','magenta','royalblue']
# fracs = [1, 25, 27, 2,8]
fracs = [8, 1, 35, 7,12]
explode = [0, 0, 0.05, 0,0.1] # 0.1 ,
plt.axes(aspect=1) # set this , Figure is round, otherwise it is an ellipse
#autopct ,show percet
patches,l_text,p_text=plt.pie(x=fracs, labels=labels, explode=explode,autopct='%3.1f %%',
shadow=True, labeldistance=1.1, startangle = 90,pctdistance = 0.6,colors=colors,
)
for t in l_text:
t.set_fontproperties(matplotlib.font_manager.FontProperties(fname="/usr/share/fonts/truetype/arphic/uming.ttc"))
zhfont = matplotlib.font_manager.FontProperties(fname="/usr/share/fonts/truetype/arphic/uming.ttc")
# plt.title(u" ",fontproperties=zhfont,y = 1.1,fontsize = 18)
plt.title(u" ",fontproperties=zhfont,y = 1.1,fontsize = 18)
'''
labeldistance, ,1.1 1.1
autopct, ,%3.1f%% ,
shadow,
startangle, ,0, 0 , 。 90
pctdistance, text
patches, l_texts, p_texts, ,p_texts ,l_texts label
'''
plt.show()