Python可视化----------matplotlib.pylot

 1  1 >>> import matplotlib.pyplot as plt
 2  2 >>> plt.axis([0,5,0,20])
 3  3 [0, 5, 0, 20]
 4  4 >>> plt.title('my first plot',fontsize=20,fontname='Times New Roman')
 5  5 <matplotlib.text.Text object at 0x0000000005254208>
 6  6 >>> plt.xlabel('counting',color='gray')
 7  7 <matplotlib.text.Text object at 0x0000000004C6F2E8>
 8  8 >>> plt.ylabel('Square value',color='gray')
 9  9 <matplotlib.text.Text object at 0x0000000004C7F080>
10 10 >>> plt.text(1,1.5,'first')
11 11 <matplotlib.text.Text object at 0x00000000022B6128>
12 12 >>> plt.text(2,4.5,'second')
13 13 <matplotlib.text.Text object at 0x0000000005280AC8>
14 14 >>> plt.text(3,9.5,'third')
15 15 <matplotlib.text.Text object at 0x0000000005280F98>
16 16 >>> plt.text(4,16.5,'fourth')
17 17 <matplotlib.text.Text object at 0x0000000005280F60>
18 18 >>> plt.text(1.1,12,'$y=x2$',fontsize=20,bbox={'facecolor':})
19 19 SyntaxError: invalid syntax
20 20 >>> plt.text(1.1,12,'$y=x2$',fontsize=20,bbox={'facecolor':'yellow','alpha':0.2})
21 21 <matplotlib.text.Text object at 0x0000000005289978>
22 22 >>> plt.grid(True)
23 23 >>> plt.plot([1,2,3,4],[1,4,9,16],'ro')
24 24 [<matplotlib.lines.Line2D object at 0x0000000005248828>]
25 25 >>> plt.plot([1,2,3,4],[0.8,3.5,8,15],'g^')
26 26 [<matplotlib.lines.Line2D object at 0x0000000005248860>]
27 27 >>> plt.plot([1,2,3,4],[0.5,2.5,4,12],'b*')
28 28 [<matplotlib.lines.Line2D object at 0x0000000004C6F7F0>]
29 29 >>> plt.legend(['first series','second series','third series'],loc=2)
30 30 <matplotlib.legend.Legend object at 0x0000000004C7FF28>
31 31 >>> plt.savefig('c:my_chart.png')
32 32 >>> plt.show()

 

posted @ 2017-04-15 21:32  Braveliberty  阅读(929)  评论(0编辑  收藏  举报