微信扫一扫打赏支持

jupyter notebook中%pylab的作用

jupyter notebook中%pylab的作用

一、总结

一句话总结:

%pylab命令会在ipython或notebook环境中自动加载numpy和matplotlib库,跟以下语句功能一致
import numpy
import matplotlib
from matplotlib import pylab, mlab, pyplot
np = numpy
plt = pyplot
from IPython.display import display
from IPython.core.pylabtools import figsize, getfigs
from pylab import *
from numpy import *

如果传递--no-import-all选项,上面最后两条语句将会不执行

 

 

二、jupyter notebook中%pylab的作用

转自或参考:ipython关于%pylab的中文说明
https://www.php.cn/python-tutorials-356737.html

 

该命令会在ipython或notebook环境中自动加载numpy和matplotlib库,跟以下语句功能一致

import numpy

import matplotlib

from matplotlib import pylab, mlab, pyplot

np = numpy

plt = pyplot



from IPython.display import display

from IPython.core.pylabtools import figsize, getfigs



from pylab import *

from numpy import *

如果传递--no-import-all选项,上面最后两条语句将会不执行

可选gui参数

指定matplotlib可用的后端,可设的参数有,'agg', 'gtk', 'gtk3', 'inline', 'ipympl', 'nbagg', 'notebook', 'osx', 'qt', 'qt4', 'qt5', 'tk', 'wx',如果设置了该参数,就会使用对应的后端,否则就使用默认的后端,当然也可以在matplotlib的配置文件中修改默认参数.



在这些参数中只有inline参数会将图表直接画在qtconsole或notebook上,其他都是在新弹出的对话框中画图。


 

 

 

 

 

 
posted @ 2020-10-23 07:06  范仁义  阅读(508)  评论(0编辑  收藏  举报