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

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

05-11 13:29