%matplotlib auto fig = plt.figure() ax = fig.add_subplot(2,2,1) ax2 = fig.add_subplot(2,2,2) ax.plot(1,3,7) ax.plot(2,5,8) plt.show
%matplotlib inline data = [32,48,21,100] labels = ['Jan','feb','Mar','Apr'] plt.bar(np.arange(len(data)),data,align='edge') plt.xticks(np.arange(len(data)),labels) plt.show()
plt.bar([1,2,5],[2,6,10])
plt.bar(np.arange(3),[2,6,10])
plt.barh(np.arange(3),[2,6,10]) plt.yticks(np.arange(3),['Jan','feb','Mar','Apr'])
一、默認是橢圓python
plt.pie([1,2,3])
二、如何設置成真正的圓形?3d
plt.pie([1,2,3]) plt.axis('equal')
三、添加標籤blog
plt.pie([1,2,3],labels=['a','b','c']) plt.axis('equal')
四、設置小數位數class
plt.pie([1,2,3],labels=['a','b','c'],autopct="%.2f",) plt.axis('equal')
五、彈出部分im
plt.pie([1,2,3],labels=['a','b','c'],autopct="%.2f",explode=[1.0,0.0,0.0]) plt.axis('equal')
六、彈出部分幅度調正d3
plt.pie([1,2,3],labels=['a','b','c'],autopct="%.2f",explode=[0.2,0.0,0.0]) plt.axis('equal')
七、綜合美圖總結
plt.pie([10,20,30,40],labels=['a','b','c','d'],autopct="%.2f%%",explode=[0.1,0,0.1,0]) plt.axis('equal')