Format: application/x-python-code
⬇ Download File (5.5 KB)
   1  o
   2  
   3  ��h��@spdZddlmZddlmZddlmZmZmZddl	m
   4  Z
   5  ddlmZej
   6  ddd	d
   7  �ZeGdd�de��Zd
   8  S)z@Implementation of magic functions for matplotlib/pylab support.
   9  �)�Application)�magic_arguments)�Magics�magics_class�
  10  line_magic)�skip_doctest)�warn�gui�?z�Name of the matplotlib backend to use such as 'qt' or 'widget'.
  11          If given, the corresponding matplotlib backend is used,
  12          otherwise it will be matplotlib's default
  13          (which you can set in your matplotlib config file).
  14          )�nargs�helpc	@sxeZdZdZeee��ejddddd�eddd	������Z	eee��ejd
  15  dddd
  16  �eddd������Z
  17  dd�ZdS)�PylabMagicsz,Magics related to matplotlib's pylab supportz-lz--list�
  18  store_truez"Show available matplotlib backends)�actionr�cCsVt�|j|�}|jrddlm}td|��dS|j�|j	�\}}|�
  19  |j	|�dS)aSet up matplotlib to work interactively.
  20  
  21          This function lets you activate matplotlib interactive support
  22          at any point during an IPython session. It does not import anything
  23          into the interactive namespace.
  24  
  25          If you are using the inline matplotlib backend in the IPython Notebook
  26          you can set which figure formats are enabled using the following::
  27  
  28              In [1]: from matplotlib_inline.backend_inline import set_matplotlib_formats
  29  
  30              In [2]: set_matplotlib_formats('pdf', 'svg')
  31  
  32          The default for inline figures sets `bbox_inches` to 'tight'. This can
  33          cause discrepancies between the displayed image and the identical
  34          image created using `savefig`. This behavior can be disabled using the
  35          `%config` magic::
  36  
  37              In [3]: %config InlineBackend.print_figure_kwargs = {'bbox_inches':None}
  38  
  39          In addition, see the docstrings of
  40          `matplotlib_inline.backend_inline.set_matplotlib_formats` and
  41          `matplotlib_inline.backend_inline.set_matplotlib_close` for more information on
  42          changing additional behaviors of the inline backend.
  43  
  44          Examples
  45          --------
  46          To enable the inline backend for usage with the IPython Notebook::
  47  
  48              In [1]: %matplotlib inline
  49  
  50          In this case, where the matplotlib default is TkAgg::
  51  
  52              In [2]: %matplotlib
  53              Using matplotlib backend: TkAgg
  54  
  55          But you can explicitly request a different GUI backend::
  56  
  57              In [3]: %matplotlib qt
  58  
  59          You can list the available backends using the -l/--list option::
  60  
  61             In [4]: %matplotlib --list
  62             Available matplotlib backends: ['osx', 'qt4', 'qt5', 'gtk3', 'gtk4', 'notebook', 'wx', 'qt', 'nbagg',
  63             'gtk', 'tk', 'inline']
  64          r)�'_list_matplotlib_backends_and_gui_loopsz!Available matplotlib backends: %sN)r�parse_argstring�
  65  matplotlib�listZIPython.core.pylabtoolsr�print�shellZenable_matplotlibr	�_show_matplotlib_backend)�self�line�argsrr	�backend�r�Oc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/magics/pylab.pyr)s5��zPylabMagics.matplotlibz--no-import-allNz�Prevent IPython from performing ``import *`` into the interactive namespace.
  66  
  67          You can govern the default behavior of this flag with the
  68          InteractiveShellApp.pylab_import_all configurable.
  69          )r�defaultrcCs�t�|j|�}|jdur(t��r%t��}z|j}Wnty$d}Ynwd}n|j}|j	j
  70  |j|d�\}}}|�|j|�t
  71  d�t
  72  d�|rStd|d�dSdS)aLoad numpy and matplotlib to work interactively.
  73  
  74          This function lets you activate pylab (matplotlib, numpy and
  75          interactive support) at any point during an IPython session.
  76  
  77          %pylab makes the following imports::
  78  
  79              import numpy
  80              import matplotlib
  81              from matplotlib import pylab, mlab, pyplot
  82              np = numpy
  83              plt = pyplot
  84  
  85              from IPython.display import display
  86              from IPython.core.pylabtools import figsize, getfigs
  87  
  88              from pylab import *
  89              from numpy import *
  90  
  91          If you pass `--no-import-all`, the last two `*` imports will be excluded.
  92  
  93          See the %matplotlib magic for more details about activating matplotlib
  94          without affecting the interactive namespace.
  95          NT)�
  96  import_allzO%pylab is deprecated, use %matplotlib inline and import the required libraries.z>Populating the interactive namespace from numpy and matplotlibz.pylab import has clobbered these variables: %sz8
  97  `%matplotlib` prevents importing * from pylab and numpy)rr�pylabZ
  98  no_import_allrZinitialized�instanceZpylab_import_all�AttributeErrorrZenable_pylabr	rrr)rrrZapprr	rZ	clobberedrrrr js,%
  99  
 100  ��
 101  ��zPylabMagics.pylabcCs |r|dkrtd|�dSdS)z'show matplotlib message backend message�autozUsing matplotlib backend: %sN)r)rr	rrrrr�s�z$PylabMagics._show_matplotlib_backend)r)�__name__�
 102  __module__�__qualname__�__doc__rrr�argument�
 103  magic_gui_argrr rrrrrr
 104  %s(
 105  �;�4r
 106  N)r'Ztraitlets.config.applicationrZIPython.corerZIPython.core.magicrrrZIPython.testing.skipdoctestr�warningsrr(r)r
 107  rrrr�<module>s�