1 回答

TA貢獻(xiàn)1850條經(jīng)驗(yàn) 獲得超11個(gè)贊
我已將代碼修改為:
fig1, axs1 = plt.subplots(2,2)
fig2, axs2 = plt.subplots(2,2)
# generate 4 datasets in a for loop
for i in range(4):
x,y = createRandomData(parameters)
fit1 = doFit1(x,y)
axs1[i//2,i%2].plot(x,y,color='black',linewidth = 1)
axs1[i//2,i%2].plot(x,fit1,color='green',linewidth = 1)
fit2 = doFit2(x,y)
axs2[i//2,i%2].plot(x,y,color='black',linewidth = 1)
axs2[i//2,i%2].plot(x,fit2,color='green',linewidth = 1)
fig1.set_size_inches(12,8)
fig1.savefig('dataWithFit1.png', dpi=200)
fig1.show()
fig2.set_size_inches(12,8)
fig2.savefig('dataWithFit2.png', dpi=200)
plt.show()
此外,最后一個(gè)繪圖命令中有一個(gè)錯(cuò)字(應(yīng)該繪制 fit2 而不是 fit1)在“偽造”帖子的代碼時(shí)引入。
它現(xiàn)在正確顯示并保存數(shù)字。但是,我仍然 UserWarning: Matplotlib is currently using module://ipykernel.pylab.backend_inline, which is a non-GUI backend, so cannot show the figure.在 jupyter notebook 中收到警告。因此,如果你們中的任何一個(gè)對(duì)此有任何見解,請(qǐng)?zhí)砑釉u(píng)論以確保完整性。
添加回答
舉報(bào)