
    ^h                         S r SSKJr  SSKJr  SSKJrJrJr  SSK	J
r
  SSKJr  SSKJr  \R                  " SS	S
\" \" \" \R&                  " 5       5      5      5      -  S9r\ " S S\5      5       rg)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            
          \ rS rSrSr\\\R                  " 5       \R                  " SSSSS9\	SS j5       5       5       5       5       r
\\\R                  " 5       \R                  " S	SS
SS9\	SS j5       5       5       5       5       rS rSrg
)PylabMagics%   z,Magics related to matplotlib's pylab supportz-lz--list
store_truez"Show available matplotlib backends)actionr   c                    [         R                  " U R                  U5      nUR                  (       a-  [        [        R
                  " 5       5      n[        SU-  5        gU R                  R                  [        UR                  [        5      (       a  UR                  R                  5       OUR                  5      u  pEU R                  UR                  U5        g)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         S/home/james-whalen/.local/lib/python3.13/site-packages/IPython/core/magics/pylab.pyr   PylabMagics.matplotlib)   s    j ..tE99 1M5EF::77JW[W_W_adLeLe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                 
   [         R                  " U R                  U5      nUR                  c@  [        R
                  " 5       (       a#  [        R                  " 5       n UR                  nOSnOUR                  (       + nU R                  R                  UR                  US9u  pVnU R                  UR                  U5        [        S5        [        S5        U(       a  [        SU-  S-   5        gg! [         a    Sn Nf = f)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+   PylabMagics.pylabf   s    J ..tzz4@%&&((!**,&!$!5!5J
 "
 "///J"&**"9"9$((z"9"Zi%%dhh8]	
 	NOAYNGH   & &!%J&s   C3 3DDc                 <    U(       a  US:X  a  [        SU-  5        gg)z'show matplotlib message backend messageautozUsing matplotlib backend: %sN)r   )r    r   r$   s      r%   r   $PylabMagics._show_matplotlib_backend   s    cVm07:; $r'    ) )__name__
__module____qualname____firstlineno____doc__r   r   r   argumentmagic_gui_argr   r+   r   __static_attributes__r8   r'   r%   r   r   %   s    6$$&dH\#GI5= I '  5=n $$&, 2  '  2h<r'   r   N)r>   traitlets.config.applicationr   IPython.corer   IPython.core.magicr   r   r   IPython.testing.skipdoctestr   warningsr	   IPython.core.pylabtoolsr
   r?   r   tuplesortedr   r@   r   r8   r'   r%   <module>rJ      sz    5 ( ? ? 4  ,  ((S %x}}/01	2 C<& C< C<r'   