matplotlib基礎(二)

16731 ワード

#    
plt.figure(figsize=(8,7))  #    
plt.plot(values[:,0],values[:,2],color='r',linestyle='--',marker="o") #marker      
plt.xlabel("  ")
plt.ylabel("    ")
plt.ylim((0,225000))
plt.xticks(range(0,70,4),values[range(0,70,4),1],rotation=45)
plt.show()

#plot        ,       ,                、       ,     3        ,        

plt.figure(figsize=(8,7))  #    
plt.plot(values[:,0],values[:,2],'bs-',
         values[:,0],values[:,4],'ro-.',
            values[:,0],values[:,5],'gH--',
         ) #marker      
plt.xlabel("  ")
plt.ylabel("    ")
plt.ylim((0,225000))
plt.xticks(range(0,70,4),values[range(0,70,4),1],rotation=45)
plt.show()

#               
"""
1.     ,            。
2.    ,             。
3.     ,             。
"""
plt.rcParams['font.sans-serif']='SmHei' #      
plt.rcParams['axes.unicode_minus']=False
data=np.load('          .npz')
name=data['columns']#     
values=data['values'] #  values  ,         
label=['    ','    ','    ']#    

print(values[-1,3:6])
plt.figure(figsize=(6,5))
plt.bar(range(3),values[-1,3:6],width=0.5) #     
plt.xlabel('  ')
plt.ylabel('    (  )')
plt.xticks(range(3),label)
plt.show()

#    
plt.figure(figsize=(6,6)) #    
label=["    ","    ","    "]
explode=[0.01,0.01,0.01]#           
plt.pie(values[-1,3:6],explode=explode,labels=label,autopct='%1.1f%%') #autopct         
plt.show()

#     
"""
        ,             ,               ,          ,    
       
"""
label=["    ","    ","    "]
gdp=(list(values[:,3]),list(values[:,4]),list(values[:,5]))
plt.figure(figsize=(6,4))
plt.boxplot(gdp,notch=True,labels=label,meanline=True) #notch           meanline       
plt.show()