備注:只是參考 實際過程中,需要用數據去填充 -18課
plt.xticks(rotation=45)X軸圖標以45°畫圖
plt.xlable() x軸是什么
plt.ylable()y軸是什么
plt.title()圖的題目
子圖的繪制:
import pandas as pd
import numpy as np
import tushare as ts
import matplotlib.pyplot as plt
%matplotlib inline
fig = plt.figure()
ax1 = fig.add_subplot(2,2,1) 2*2的圖形,位置在1,2,4的位置
ax2 = fig.add_subplot(2,2,2)
ax3 = fig.add_subplot(2,2,4)
fig = plt.figure(figsize=(6,6)) figsize=(6,6)指定圖片的大小
ax1 = fig.add_subplot(2,1,1)
ax2 = fig.add_subplot(2,1,2)
ax1.plot(np.random.randint(1,5,5),np.arange(5))
ax2.plot(np.arange(10)*3,np.arange(10))
plt.show()
若是在一個途中畫兩條線:
plt.plot(x,y,c=’red’) 紅色的
plt.plot(z,u,c=’blue’)
fig=plt.figure(figsize(10,6))
colors=[‘red’,’blue’,’gree’,’orange’,’black’]
for I in range(5):
start_index = I *12
end_index =(I +1 )*12
subset =unrate[start_index:end_index] #取值
lable = str(1948+I)
plt.plot(subset[‘MONTH’],subset[‘VALUE’],c =colors[i],lable=lable)
plt.legend(loc=’best’)
plt.show()
