
    f                         d Z ddlmZ ddlmZ ddlmZmZmZ ddl	m
Z
 ddlmZ ddlmZ  ej                  dd	d
 e e e ej&                                           z        Ze G d de             Zy)z@Implementation of magic functions for matplotlib/pylab support.
    )Application)magic_arguments)Magicsmagics_class
line_magic)skip_doctest)warn)backendsgui?zName of the matplotlib backend to use %s.
        If given, the corresponding matplotlib backend is used,
        otherwise it will be matplotlib's default
        (which you can set in your matplotlib config file).
        )nargshelpc            	          e Zd ZdZee ej                          ej                  dddd      edd                                   Z	ee ej                          ej                  ddd	d
      edd                                   Z
d Zy	)PylabMagicsz,Magics related to matplotlib's pylab supportz-lz--list
store_truez"Show available matplotlib backends)actionr   c                    t        j                  | j                  |      }|j                  r,t        t	        j
                               }t        d|z         y| j                  j                  t        |j                  t              r|j                  j                         n|j                        \  }}| j                  |j                  |       y)a  Set up matplotlib to work interactively.

        This function lets you activate matplotlib interactive support
        at any point during an IPython session. It does not import anything
        into the interactive namespace.

        If you are using the inline matplotlib backend in the IPython Notebook
        you can set which figure formats are enabled using the following::

            In [1]: from matplotlib_inline.backend_inline import set_matplotlib_formats

            In [2]: set_matplotlib_formats('pdf', 'svg')

        The default for inline figures sets `bbox_inches` to 'tight'. This can
        cause discrepancies between the displayed image and the identical
        image created using `savefig`. This behavior can be disabled using the
        `%config` magic::

            In [3]: %config InlineBackend.print_figure_kwargs = {'bbox_inches':None}

        In addition, see the docstrings of
        `matplotlib_inline.backend_inline.set_matplotlib_formats` and
        `matplotlib_inline.backend_inline.set_matplotlib_close` for more information on
        changing additional behaviors of the inline backend.

        Examples
        --------
        To enable the inline backend for usage with the IPython Notebook::

            In [1]: %matplotlib inline

        In this case, where the matplotlib default is TkAgg::

            In [2]: %matplotlib
            Using matplotlib backend: TkAgg

        But you can explicitly request a different GUI backend::

            In [3]: %matplotlib qt

        You can list the available backends using the -l/--list option::

           In [4]: %matplotlib --list
           Available matplotlib backends: ['osx', 'qt4', 'qt5', 'gtk3', 'gtk4', 'notebook', 'wx', 'qt', 'nbagg',
           'gtk', 'tk', 'inline']
        z!Available matplotlib backends: %sN)r   parse_argstring
matplotliblistr
   keysprintshellenable_matplotlib
isinstancer   strlower_show_matplotlib_backend)selflineargsbackends_listr   backends         T/var/www/cvtools/html/venv/lib/python3.12/site-packages/IPython/core/magics/pylab.pyr   zPylabMagics.matplotlib)   s    j ..tE99 1M5EF::77JW[W_W_adLe8HkokskstLC))$((G<    z--no-import-allNzPrevent IPython from performing ``import *`` into the interactive namespace.

        You can govern the default behavior of this flag with the
        InteractiveShellApp.pylab_import_all configurable.
        )r   defaultr   c                    t        j                  | j                  |      }|j                  9t	        j
                         r"t	        j                         }	 |j                  }nd}n|j                   }| j                  j                  |j                  |      \  }}}| j                  |j                  |       t        d       t        d       |rt        d|z  dz          yy# t        $ r d}Y w xY w)a  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 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.
        NT)
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
`%matplotlib` prevents importing * from pylab and numpy)r   r   pylabno_import_allr   initializedinstancepylab_import_allAttributeErrorr   enable_pylabr   r   r   r	   )r   r    r!   appr(   r   r#   	clobbereds           r$   r)   zPylabMagics.pylabf   s    J ..tzz4@%&&(!**,&!$!5!5J
 "
 "///J"&**"9"9$((z"9"ZWi%%dhh8]	
 	NOAYNGH   & &!%J&s   C% %C32C3c                 0    |r|dk(  rt        d|z         yy)z'show matplotlib message backend messageautozUsing matplotlib backend: %sN)r   )r   r   r#   s      r$   r   z$PylabMagics._show_matplotlib_backend   s    cVm07:; $r%   ) )__name__
__module____qualname____doc__r   r   r   argumentmagic_gui_argr   r)   r    r%   r$   r   r   %   s    6$_$$&_dH\#GI5= I '  5=n $_$$&_, 2  '  2h<r%   r   N)r8   traitlets.config.applicationr   IPython.corer   IPython.core.magicr   r   r   IPython.testing.skipdoctestr   warningsr	   IPython.core.pylabtoolsr
   r9   r   tuplesortedr   r:   r   r;   r%   r$   <module>rD      s~    5 ( ? ? 4  , )((S %}x}}/01	2 C<& C< C<r%   