引用自:http://www.cnblogs.com/super-zhang-828/p/4792206.html
import matplotlib.pyplot as plt
plt.plot([1,2,3],[4,5,6],'ro')
plt.show()#這個智障的編輯器,,,看來高版本的確修復了一些bug
用python3的qt5出來的圖形,效果很好:
而且在上面的圖像中也可以用調整按鈕進行適當的調整。
下面我們直接用代碼進行坐標的調整:
import matplotlib.pyplot as plt plt.xlim(xmax=7,xmin=0) plt.ylim(ymax=7,ymin=0) plt.plot([1,2,3],[4,5,6],'ro') plt.show()
下面加一個標題,叫做散點圖
import matplotlib.pyplot as plt
plt.title("I'm a scatter diagram.") plt.xlim(xmax=7,xmin=0) plt.ylim(ymax=7,ymin=0) plt.plot([1,2,3],[4,5,6],'ro') plt.show()

給xy軸進行命名
import matplotlib.pyplot as plt plt.title("I'm a scatter diagram.") plt.xlim(xmax=7,xmin=0) plt.ylim(ymax=7,ymin=0)
plt.xlabel("x")
plt.ylabel("y") plt.plot([1,2,3],[4,5,6],'ro') plt.show()

加一個標注:
import matplotlib.pyplot as plt plt.title("I'm a scatter diagram.") plt.xlim(xmax=7,xmin=0) plt.ylim(ymax=7,ymin=0) plt.annotate("(3,6)", xy = (3, 6), xytext = (4, 5), arrowprops = dict(facecolor = 'black', shrink = 0.1)) plt.xlabel("x") plt.ylabel("y") plt.plot([1,2,3],[4,5,6],'ro') plt.show()
多畫幾個圖:
import matplotlib.pyplot as plt plt.subplot(221) plt.xlim(xmax=7,xmin=0) plt.ylim(ymax=7,ymin=0) plt.xlabel("x") plt.ylabel("y") plt.plot([1,2,3],[4,5,6],'ro') plt.subplot(222) plt.xlim(xmax=7,xmin=0) plt.ylim(ymax=7,ymin=0) plt.xlabel("x") plt.ylabel("y") plt.plot([1,2,3],[4,5,6],'ro') plt.subplot(223) plt.xlim(xmax=7,xmin=0) plt.ylim(ymax=7,ymin=0) plt.xlabel("x") plt.ylabel("y") plt.plot([1,2,3],[4,5,6],'ro') plt.show()