Notes(2019.04.06):
Data Visiable with matplotlib.pyplot - Using matplotlib.pyplot:
>>> import matplotlib.pyplot as plt
New Words:
plot = picture = figure
sub-A:the child of A
First:
#title中的loc只可以放在上方的left/center/right!
0.Draw many sub-figures in one main-figure
plt.figure(num=2)
1.indicate a area of number
numpy.arange(1,10,2) #can own float in it!!!
range(1,10,2) #only integer!!!
np.array([...]) #any type!!!
attention:the two ways above support index and slice visit
2.divide area of figure (row,column,position -> from row)
matplotlib.pyplot.subplot(2,2,1)
matplotlib.pyplot.subplot(221)
matplotlib.pyplot.show()
3.scatter figure
matplotlib.pyplot.scatter(List1,List2,color,marker)
matplotlib.pyplot.title("...")
matplotlib.pyplot.show()
4.plot figure
plt.plot(List1,List2,color='red','o-/o/-/./--/-./:')
plt.plot(x, y, 'ro-',label="xxx") # red+solid-point+line
plt.xlabel("...")
plt.ylabel("...")
matplotlib.pyplot.title("...")
plt.xlim(a,b) # limit the x-axis
plt.ylim(c,d) # limit the y-axis
plt.grid() #show grid
plt.legend(loc="upper left") #generate legend by plot-labels
matplotlib.pyplot.show()
5.bar figure
def draw_bar():
x = np.array(["Frank", "kiroto", "pixel", "Lisa", "Bostor"])
y = np.array([45, 12, 23, 78, 9])
z = np.array([12, 45, 55, 19, 66])
plt.subplot(211)
plt.bar(np.arange(5), y, width=0.3, color='red', label="Life")
plt.bar(np.arange(5)+0.3, z, width=0.3, color='green', label="Entertainment")
plt.title("Person's ability", fontsize=12)
plt.xlabel("Name", fontsize=12)
plt.ylabel("Score", fontsize=12)
plt.grid()
plt.legend(loc='upper left')
plt.subplot(212)
plt.bar(x, height=y, color='red', width=0.3, label='Life')
plt.title("Person's ability", fontsize=12)
plt.xlabel("Name", fontsize=12)
plt.ylabel("Score", fontsize=12)
plt.xticks([0, 1, 2, 3, 4], ["A", "B", "C", "D", "E"])
plt.grid()