1. 程式人生 > >Python篇:用python畫xy散點圖

Python篇:用python畫xy散點圖

python畫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.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()