import numpy as np
import matplotlib.pyplot as plt
x = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 0])
y = np.array([1, 3, 4, 6, 7, 2, 13, 24, 6, 19])
plt.plot(x, y, 'r') # 折線圖,第一個參數是x座標軸,第二個參數是y座標軸的數
plt.plot(x, y, 'g', lw=3) # 第三個參數是折線的顏色規定,第四個是折現的線條寬度
x = np.array([12, 2, 3, 4, 5, 6, 7, 8, 9, 0])
y = np.array([11, 3, 4, 6, 7, 2, 13, 24, 6, 19])
plt.bar(x, y, 0.5, alpha=1, color='b') # 柱狀圖,第一個,第二個參數同理,第三個是規定柱狀圖的寬度,如果是1則柱狀圖是挨着的,很寬
plt.show() # 第四個參數是柱狀圖的透明度,第五個是柱狀圖的顏色
這裏就用上述代碼簡單解釋一下matplotlib這個畫圖的工具,實現的效果是: