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

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

matplotlib:從命令行運(yùn)行 ipython 時(shí),在 Web 瀏覽器中按順序顯示繪圖

matplotlib:從命令行運(yùn)行 ipython 時(shí),在 Web 瀏覽器中按順序顯示繪圖

江戶川亂折騰 2022-01-05 10:35:08
目前,我有 3 個(gè)帶有 pyplot 的單獨(dú)窗口......我不想要......我想在一個(gè)類似于 jupyter 輸出的單個(gè) Web 瀏覽器窗口中看到我的所有圖按順序“內(nèi)聯(lián)”列出,除了我的腳本從作為 ipython 腳本的 Windows 命令行...# File: plotit.ipy# toy ipython plotting exampleimport numpy as npimport matplotlib.pyplot as plt %matplotlibt = np.linspace(0, 10, 100)y1 = 5*ty2 = -0.5*ty3 = 2*t**2# display as 1st inline graph in "jupyter web browser window"plt.figure()plt.plot(t,y1)plt.show()# display as 2nd inline graph in "jupyter web browser window"plt.figure()plt.plot(t,y2)plt.show()# display as 3rd inline graph in "jupyter web browser window"plt.figure()plt.plot(t,y3, '.')plt.show()這是我使用 ActiveState Python 3.6 從命令行運(yùn)行它的方式:C:\> ipython In [1]: %run testit.ipyUsing matplotlib backend: TkAgg    有沒有辦法將 Jupiter 文檔轉(zhuǎn)換為 ipython 腳本,并從命令行將它作為一個(gè)整體腳本運(yùn)行,但仍然讓 matplotlib 圖在 jupyter 輸出窗口中按順序顯示為“內(nèi)聯(lián)”腳本。
查看完整描述

2 回答

?
慕標(biāo)5832272

TA貢獻(xiàn)1966條經(jīng)驗(yàn) 獲得超4個(gè)贊

我不知道是否可以模擬 jupyter 筆記本,而無需實(shí)際運(yùn)行它。


另一種方法是使用webagg后端。在這種情況下,只plt.show()在末尾放置一個(gè)調(diào)用以在同一頁面上顯示所有三個(gè)數(shù)字。


import numpy as np

import matplotlib

matplotlib.use("webagg")

import matplotlib.pyplot as plt 



t = np.linspace(0, 10, 100)

y1 = 5*t

y2 = -0.5*t

y3 = 2*t**2


# display as 1st inline graph in "jupyter web browser window"

plt.figure()

plt.plot(t,y1)


# display as 2nd inline graph in "jupyter web browser window"

plt.figure()

plt.plot(t,y2)


# display as 3rd inline graph in "jupyter web browser window"

plt.figure()

plt.plot(t,y3, '.')

plt.show()

運(yùn)行此程序時(shí),應(yīng)打開一個(gè)瀏覽器窗口,并顯示三個(gè)數(shù)字

http://img1.sycdn.imooc.com//61d503fa000195f310870920.jpg

查看完整回答
反對(duì) 回復(fù) 2022-01-05
?
天涯盡頭無女友

TA貢獻(xiàn)1831條經(jīng)驗(yàn) 獲得超9個(gè)贊

將所有繪圖保存為圖像文件而不顯示它們,然后在運(yùn)行python腳本后編寫一個(gè)html文件來顯示所有圖像文件。


# File: plotit.ipy


# toy ipython plotting example

import numpy as np

import matplotlib.pyplot as plt 


t = np.linspace(0, 10, 100)

y1 = 5*t

y2 = -0.5*t

y3 = 2*t**2


# display as 1st inline graph in jupyter web browser window

fig = plt.figure()

plt.plot(t,y1)

fig.savefig("plot1.png")


# display as 2nd inline graph in jupyter web browser window

fig = plt.figure()

plt.plot(t,y2)

fig.savefig("plot2.png")


# display as 3rd inline graph in jupyter web browser window

fig = plt.figure()

plt.plot(t,y3)

fig.savefig("plot3.png")

html:


<!-- FILE: results.html -->

<html>

<body>

    <img src="plot1.png"/><br>

    <img src="plot2.png"/><br>

    <img src="plot3.png"/><br>

</body>

</html>

另一個(gè) html 結(jié)果頁面:


<h1>Results</h1>


<table>


<tr>

<td><img src="plot1.png" style="max-width:100%"/></td>

<td><img src="plot2.png" style="max-width:100%"/></td>

</tr>


<tr>

<td><img src="plot3.png" style="max-width:100%"/></td>

<td><img src="plot1.png" style="max-width:100%"/></td>

</tr>


</table>


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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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