這次主要學(xué)習(xí)的是matplotlib的框架,原來一張圖表有這么多講究,真是學(xué)習(xí)了。
### 第一回
# fig,ax= plt.subplots()
# ax.plot([1,2,3,4],[1,4,2,3])
# plt.show()
# line = plt.plot([1,2,3,4],[1,4,2,3])
# x = np.linspace(0,2,100)
# fig,ax = plt.subplots()
# ax.plot(x,x,label = 'linear')
# ax.plot(x,x**2,label='quadratic')
# ax.plot(x,x**3,label='cubic')
# ax.set_xlabel('x label')
# ax.set_ylabel('y label')
# ax.set_title('Simple Plot')
# ax.legend()
# plt.show()
# x = np.linspace(0,2,100)
# plt.plot(x,x,label = 'linear')
# plt.plot(x,x**2,label = 'quadratic')
# plt.plot(x,x**3,label = 'cubic')
# plt.xlabel('x label')
# plt.ylabel('y label')
# plt.title('Simple Plot')
# plt.legend()
# plt.show()
# ## 通用模板
# # step1 準(zhǔn)備數(shù)據(jù)
# x = np.linspace(0,2,100)
# y = x**2
# # step2 設(shè)置繪圖樣式
# mpl.rc('lines',linewidth = 4,linestyle = '-.')
# # step3 定義布局
# fig,ax = plt.subplots()
# # step4 繪制圖像
# ax.plot(x,y,label = 'linear')
# # step5 添加標(biāo)簽、文字和圖例
# ax.set_xlabel('x label')
# ax.set_ylabel('y label')
# ax.set_title('Simple Plot')
# ax.legend();
## 思考題
# 1、請思考兩種繪圖模式的優(yōu)缺點(diǎn)和各自適合的使用場景
# 2、在第五節(jié)繪圖模板中我們是以O(shè)O模型作為例子展示的,請思考并寫一個pyplot繪圖模式的簡單模板
# 1
# (1)顯式創(chuàng)建適合需要創(chuàng)建多個圖時,自動創(chuàng)建適合只有一張圖時
# 2
# x = np.linspace(0,2,100)
# y = x**2
# plt.plot(x,y,label = 'linear')
# plt.xlabel('x label')
# plt.ylabel('y label')
# plt.title('自動創(chuàng)建')
# plt.legend()
# plt.show();