第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

將多個(gè)數(shù)字保存到單獨(dú)的文件中,即使它們正確顯示()也不起作用

將多個(gè)數(shù)字保存到單獨(dú)的文件中,即使它們正確顯示()也不起作用

猛跑小豬 2022-10-18 14:56:46
我正在嘗試生成兩個(gè)不同的圖形來(lái)分隔使用相同基本數(shù)據(jù)的文件(.png 圖像),但我得到了空白的白色圖像。但是,當(dāng)在帶有 plt.show() 語(yǔ)句的 jupyter 筆記本中顯示時(shí),這兩個(gè)數(shù)字似乎都不錯(cuò)。我的相關(guān)代碼如下所示:plt.figure(1)fig1, axs1 = plt.subplots(2,2)plt.figure(2)fig2, axs2 = plt.subplots(2,2)# generate 4 datasets in a for loopfor i in range(4):     x,y = createRandomData(parameters)    fit1 = doFit1(x,y)    plt.figure(1)    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)    plt.figure(2)    axs2[i//2,i%2].plot(x,y,color='black',linewidth = 1)    axs2[i//2,i%2].plot(x,fit1,color='green',linewidth = 1)plt.figure(1)plt.gcf().set_size_inches(12,8)plt.gcf().savefig('dataWithFit1.png', dpi=200)plt.show()plt.figure(2)plt.gcf().set_size_inches(12,8)plt.gcf().savefig('dataWithFit2.png', dpi=200)plt.show()無(wú)法弄清楚為什么 savefig() 不產(chǎn)生正確的輸出,即使下面的 show() 語(yǔ)句產(chǎn)生正確的輸出到 jupyter notebook 內(nèi)的瀏覽器。我也嘗試過(guò) variablefig1而不是plt.gcf().有什么建議么?
查看完整描述

1 回答

?
慕蓋茨4494581

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)論以確保完整性。


查看完整回答
反對(duì) 回復(fù) 2022-10-18
  • 1 回答
  • 0 關(guān)注
  • 171 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)