人妖在线一区,国产日韩欧美一区二区综合在线,国产啪精品视频网站免费,欧美内射深插日本少妇

新聞動(dòng)態(tài)

Python Matplotlib庫(kù)實(shí)現(xiàn)畫(huà)局部圖

發(fā)布日期:2021-12-10 08:01 | 文章來(lái)源:源碼中國(guó)

在畫(huà)圖中,我們需要放大圖像的某一部分,看清其變化。最近在寫(xiě)論文時(shí),就遇到了這個(gè)問(wèn)題,還有坐標(biāo)軸加粗、控制線(xiàn)型和大小等要求。這些,都可以通過(guò)Python Matplotlib庫(kù)實(shí)現(xiàn)。具體看下面的代碼:

import matplotlib.pyplot as plt
init_np = np.array(x0_list)
xopt_net_np = np.array(xopt_net)
plt.figure(figsize=(8,5))
plt.subplot(311)
ax = plt.gca() # 獲取坐標(biāo)軸
bwith = 1.2
ax.spines['bottom'].set_linewidth(bwith)
ax.spines['left'].set_linewidth(bwith)
ax.spines['top'].set_linewidth(bwith)
ax.spines['right'].set_linewidth(bwith)
plt.yticks([])
plt.xlim([-21,21])
plt.plot(init_np, np.zeros_like(init_np), '.b', markersize=2, label='initial value Distri.')
plt.legend()
plt.subplot(312)
ax = plt.gca()
bwith = 1.2
ax.spines['bottom'].set_linewidth(bwith)
ax.spines['left'].set_linewidth(bwith)
ax.spines['top'].set_linewidth(bwith)
ax.spines['right'].set_linewidth(bwith)
plt.yticks([])
plt.xlabel('x')
plt.plot(xopt_gd, np.zeros_like(xopt_gd), '.r', markersize=2, label='optimal value Distri. by GD')
plt.xlim([-21,21])
plt.legend()
plt.subplot(313)
ax = plt.gca()
bwith = 1.2
ax.spines['bottom'].set_linewidth(bwith)
ax.spines['left'].set_linewidth(bwith)
ax.spines['top'].set_linewidth(bwith)
ax.spines['right'].set_linewidth(bwith)
plt.yticks([])
plt.plot(xopt_net_np, np.zeros_like(xopt_net_np), '.r', markersize=2, label='optimal value Distri. by Network')
plt.xlim([-21,21])
plt.legend()
plt.axes([0.125,0.275,0.25,0.07])# list:[左下角水平坐標(biāo), 左下角垂直坐標(biāo), 寬度, 高度]
# plt.xticks(())
plt.yticks(())
plt.plot(xopt_net_np, np.zeros_like(xopt_net_np), '.r', markersize=1, label='optimal value Distr.')
plt.savefig('sol_scipy_ai.png', dpi=400, bbox_inches='tight')
plt.show()

得到了下面的效果:

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持本站。

版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。

相關(guān)文章

實(shí)時(shí)開(kāi)通

自選配置、實(shí)時(shí)開(kāi)通

免備案

全球線(xiàn)路精選!

全天候客戶(hù)服務(wù)

7x24全年不間斷在線(xiàn)

專(zhuān)屬顧問(wèn)服務(wù)

1對(duì)1客戶(hù)咨詢(xún)顧問(wèn)

在線(xiàn)
客服

在線(xiàn)客服:7*24小時(shí)在線(xiàn)

客服
熱線(xiàn)

400-630-3752
7*24小時(shí)客服服務(wù)熱線(xiàn)

關(guān)注
微信

關(guān)注官方微信
頂部