jupyter notebook matplotlib繪制動態圖並顯示在notebook中
一、總結
一句話總結:
引入pylab庫,加上%pylab就可以畫出動態庫了:Using matplotlib backend: Qt5Agg
from matplotlib import pylab %pylab Using matplotlib backend: Qt5Agg Populating the interactive namespace from numpy and matplotlib
二、jupyter notebook matplotlib繪制動態圖並顯示在notebook中
轉自或參考:jupyter notebook matplotlib繪制動態圖並顯示在notebook中
https://blog.csdn.net/ouyangandy/article/details/82852511
有些時候matplotlib 的繪圖沒法顯示在notebook中,或者顯示不了。這與backend有關。
首先啟動你的notebook,輸入
%pylab
查看你的matplotlib后端,我的輸出為:
Qt5Agg
這是后端的渲染方式,使用的是qt5渲染。激活方式為在繪圖之前插入代碼段:
%matplotlib qt5
這樣就能顯示出圖,但是是顯示在notebook之外的,如果我使用%matplotlib inline,圖的顯示並不正常。我也不知道為什么,,,,,,,,,,,,,
如果你輸出的后端為其他類型,建議查看下面的資料,直接輸入對應的繪圖激活方式。