1. 程式人生 > >jupyter notebook在網頁上顯示作圖

jupyter notebook在網頁上顯示作圖

jupyter notebook matplotlib

今天嘗試使用jupyter notebook作圖像展示工具時,發現用matplotlib所作的圖像會自動啟動一個圖像展示窗口,無法顯示在網頁上,而我的初衷是使用jupyter notebook做圖像即時呈現及存儲(有點類似PPT作圖)。

隨機生成一批正弦數據:

import numpy as np
import matplotlib.pyplot as plt

x=np.arange(10)
y=np.sin(x)
plt.plot(x,y)
plt.show()

使用%matplotlib命令可以將matplotlib的圖表直接嵌入到Notebook之中,或者使用指定的界面庫顯示圖表,它通過參數指定matplotlib圖表的顯示方式。參數inline表示將圖表嵌入到Notebook中。將該命令加入到上面的代碼中,成功實現所需功能。

技術分享

本文出自 “abe” 博客,請務必保留此出處http://abezoo.blog.51cto.com/7223683/1956758

jupyter notebook在網頁上顯示作圖