Według mnie, pomiędzy %matplotlib, a %pylab, jest niewielka ale istotna różnica. Niestety Ty jej nie widzisz, bo masz notebooka ze skonfigurowanym już "startowo" środowiskiem. A że nie masz tam ustawionego inline, to już inna sprawa. Teraz właśnie dokładnie, widać to o czym pisałem, nie potrzebujesz ani jednej ani drugiej instrukcji, aby u Ciebie działały programy korzystające z numpy [load] czy z biblioteki matplot [imshow].
Jaka jest więc ta różnica, pomiędzy %matlibplot, a %pylab?
A no taka, że %matplotlib ładuje tylko moduł i wszystko cp trzeba tylko do rysowania [plotowanie], ale nie ładuje np numpa.
%pylab [conajmnie] ładuje zarówno numpa jak i moduł[y] ładowany[e] przez %matplotlib
I to właśnie widzę u siebie, pomijając przełącznik inline i co zapewne opisane jest w dokumentacji np: %maplotlib? czy %pylab?, ale komu by się tam chciało to czytać i sprawdzać [mi się nie chce/chciało :wink:]
[bbone=text,2315]%pylab?
%pylab [--no-import-all] [gui]
Load numpy and matplotlib to work interactively.
This function lets you activate pylab (matplotlib, numpy and
interactive support) at any point during an IPython session.
%pylab makes the following imports::
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 IPython.display import display
from IPython.core.pylabtools import figsize, getfigs
from pylab import *
from numpy import *
If you pass --no-import-all
, the last two *
imports will be excluded.
See the %matplotlib magic for more details about activating matplotlib
without affecting the interactive namespace.
positional arguments:
gui Name of the matplotlib backend to use ('gtk', 'inline',
'osx', 'qt', 'qt4', 'tk', 'wx'). If given, the
corresponding matplotlib backend is used, otherwise it will
be matplotlib's default (which you can set in your
matplotlib config file).
optional arguments:
--no-import-all Prevent IPython from performing import *
into the
interactive namespace. You can govern the default behavior
of this flag with the InteractiveShellApp.pylab_import_all
configurable.
(END)
[/bbone]
Już tu nie będę wklejał %matplotlib?