§
    OŠtjã  ã                   óN   — d dl mZ d dlmc mc mZ ddgiZ G d„ d¦  «        ZdS )é    )Úimport_moduleN)ÚPlotGridÚ
matplotlibc                   ój   — e Zd ZdZdddœd„Zd„ Zed„ ¦   «         Zed„ ¦   «         Zd	„ Z	d
„ Z
d„ Zd„ ZdS )r   aÁ	  This class helps to plot subplots from already created SymPy plots
    in a single figure.

    Examples
    ========

    .. plot::
       :context: close-figs
       :format: doctest
       :include-source: True

        >>> from sympy import symbols
        >>> from sympy.plotting import plot, plot3d, PlotGrid
        >>> x, y = symbols('x, y')
        >>> p1 = plot(x, x**2, x**3, (x, -5, 5))
        >>> p2 = plot((x**2, (x, -6, 6)), (x, (x, -5, 5)))
        >>> p3 = plot(x**3, (x, -5, 5))
        >>> p4 = plot3d(x*y, (x, -5, 5), (y, -5, 5))

    Plotting vertically in a single line:

    .. plot::
       :context: close-figs
       :format: doctest
       :include-source: True

        >>> PlotGrid(2, 1, p1, p2)
        PlotGrid object containing:
        Plot[0]:Plot object containing:
        [0]: cartesian line: x for x over (-5.0, 5.0)
        [1]: cartesian line: x**2 for x over (-5.0, 5.0)
        [2]: cartesian line: x**3 for x over (-5.0, 5.0)
        Plot[1]:Plot object containing:
        [0]: cartesian line: x**2 for x over (-6.0, 6.0)
        [1]: cartesian line: x for x over (-5.0, 5.0)

    Plotting horizontally in a single line:

    .. plot::
       :context: close-figs
       :format: doctest
       :include-source: True

        >>> PlotGrid(1, 3, p2, p3, p4)
        PlotGrid object containing:
        Plot[0]:Plot object containing:
        [0]: cartesian line: x**2 for x over (-6.0, 6.0)
        [1]: cartesian line: x for x over (-5.0, 5.0)
        Plot[1]:Plot object containing:
        [0]: cartesian line: x**3 for x over (-5.0, 5.0)
        Plot[2]:Plot object containing:
        [0]: cartesian surface: x*y for x over (-5.0, 5.0) and y over (-5.0, 5.0)

    Plotting in a grid form:

    .. plot::
       :context: close-figs
       :format: doctest
       :include-source: True

        >>> PlotGrid(2, 2, p1, p2, p3, p4)
        PlotGrid object containing:
        Plot[0]:Plot object containing:
        [0]: cartesian line: x for x over (-5.0, 5.0)
        [1]: cartesian line: x**2 for x over (-5.0, 5.0)
        [2]: cartesian line: x**3 for x over (-5.0, 5.0)
        Plot[1]:Plot object containing:
        [0]: cartesian line: x**2 for x over (-6.0, 6.0)
        [1]: cartesian line: x for x over (-5.0, 5.0)
        Plot[2]:Plot object containing:
        [0]: cartesian line: x**3 for x over (-5.0, 5.0)
        Plot[3]:Plot object containing:
        [0]: cartesian surface: x*y for x over (-5.0, 5.0) and y over (-5.0, 5.0)

    TN)ÚshowÚsizec                ó(  — t          ddg d¢idt          f¬¦  «        | _        || _        || _        g | _        d| _        || _        |D ]!}| j                             |j        ¦  «         Œ"|| _	        |r| j        r|  
                    ¦   «          dS dS dS )aá  
        Parameters
        ==========

        nrows :
            The number of rows that should be in the grid of the
            required subplot.
        ncolumns :
            The number of columns that should be in the grid
            of the required subplot.

        nrows and ncolumns together define the required grid.

        Arguments
        =========

        A list of predefined plot objects entered in a row-wise sequence
        i.e. plot objects which are to be in the top row of the required
        grid are written first, then the second row objects and so on

        Keyword arguments
        =================

        show : Boolean
            The default value is set to ``True``. Set show to ``False`` and
            the function will not display the subplot. The returned instance
            of the ``PlotGrid`` class can then be used to save or display the
            plot by calling the ``save()`` and ``show()`` methods
            respectively.
        size : (float, float), optional
            A tuple in the form (width, height) in inches to specify the size of
            the overall figure. The default value is set to ``None``, meaning
            the size will be set by the default backend.
        r   Úfromlist)ÚpyplotÚcmÚcollectionsz1.1.0)Úimport_kwargsÚmin_module_versionÚcatchN)r   ÚRuntimeErrorr   ÚnrowsÚncolumnsÚ_seriesÚ_figÚargsÚappendr   r   )Úselfr   r   r   r   r   ÚkwargsÚargs           úU/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sympy/plotting/plotgrid.pyÚ__init__zPlotGrid.__init__\   s¿   € õF (¨Ø%Ð'FÐ'FÐ'FÐGØ&­|¨oð?ñ ?ô ?ˆŒð ˆŒ
Ø ˆŒØˆŒØˆŒ	ØˆŒ	Øð 	-ð 	-ˆCØŒL×Ò ¤Ñ,Ô,Ð,Ð,ØˆŒ	Øð 	�D”Oð 	Ø�IŠI‰KŒKˆKˆKˆKð	ð 	ð 	ð 	ó    c                 óŒ  — | j         j                             | j        | j        ¦  «        }i }d}t          | j        ¦  «        D ]N}t          | j        ¦  «        D ]7}|t          | j        ¦  «        k     r| j        |         ||||f         <   |dz  }Œ8ŒO| j        si nd| j        i} | j         j	        j
        di |¤Ž| _        |                     ¦   «         D ]o\  }}t          |j        ¦  «        dk    r|j        d         j        rddini } | j        j        |fi |¤Ž}	| j        |_        |	|_        |                     ¦   «          Œpd S )Nr   é   ÚfigsizeÚ
projectionÚ3d© )r   ÚgridspecÚGridSpecr   r   ÚrangeÚlenr   r   r   Úfigurer   Úitemsr   Úis_3DÚadd_subplotÚ_plotgrid_figÚ_plotgrid_axÚprocess_series)
r   ÚgsÚmappingÚcÚiÚjÚkwÚspecÚpÚcur_axs
             r   Ú_create_figurezPlotGrid._create_figure�   sk  € ØŒ_Ô%×.Ò.¨t¬z¸4¼=ÑIÔIˆØˆØˆÝ�t”zÑ"Ô"ð 	ð 	ˆAÝ˜4œ=Ñ)Ô)ð ð �Ø•s˜4œ9‘~”~Ò%Ð%Ø(,¬	°!¬�G˜B˜q !˜tœHÑ%Ø�Q‘��ðð
 ”yÐ<ˆRˆR y°$´)Ð&<ˆØ1�D”OÔ*Ô1Ð7Ð7°BÐ7Ð7ˆŒ	Ø—}’}‘”ð 	ð 	‰GˆD�!Ý+.¨q¬y©>¬>¸AÒ+=Ð+=Ø”	˜!”Ô"ð ,>�< Ð&Ð&Ø)+ð à*�T”YÔ*¨4Ð6Ð6°2Ð6Ð6ˆFØ"œiˆAŒOØ#ˆAŒNØ×ÒÑÔÐÐð	ð 	r   c                 óF   — | j         s|                      ¦   «          | j         S ©N)r   r8   ©r   s    r   ÚfigzPlotGrid.fig¡   s&   € àŒyð 	"Ø×ÒÑ!Ô!Ð!ØŒyÐr   c                 ó   — | S r:   r#   r;   s    r   Ú_backendzPlotGrid._backend§   s   € àˆr   c                 óN   — | j         j                             | j        ¦  «         d S r:   )r   r   Úcloser<   r;   s    r   r@   zPlotGrid.close«   s#   € ØŒÔ×$Ò$ T¤XÑ.Ô.Ð.Ð.Ð.r   c                 ó¸   — t           j        r9| j                             ¦   «          | j        j                             ¦   «          d S |                      ¦   «          d S r:   )Úbase_backendÚ_showr<   Útight_layoutr   r   r   r@   r;   s    r   r   zPlotGrid.show®   sO   € ÝÔð 	ØŒH×!Ò!Ñ#Ô#Ð#ØŒOÔ"×'Ò'Ñ)Ô)Ð)Ð)Ð)à�JŠJ‰LŒLˆLˆLˆLr   c                 ó:   — | j                              |¦  «         d S r:   )r<   Úsavefig)r   Úpaths     r   ÚsavezPlotGrid.saveµ   s   € ØŒ×Ò˜ÑÔÐÐÐr   c                 ón   — d„ t          | j        ¦  «        D ¦   «         }dd                     |¦  «        z   S )Nc                 ó>   — g | ]\  }}d |z  t          |¦  «        z   ‘ŒS )z	Plot[%d]:)Ústr)Ú.0r2   Úplots      r   ú
<listcomp>z$PlotGrid.__str__.<locals>.<listcomp>¹   s;   € ð ;ð ;ð ;Ù!˜!˜Tð " A‘o­¨T©¬Ñ2ð ;ð ;ð ;r   zPlotGrid object containing:
ú
)Ú	enumerater   Újoin)r   Ú	plot_strss     r   Ú__str__zPlotGrid.__str__¸   sC   € ð;ð ;Ý%.¨t¬yÑ%9Ô%9ð;ñ ;ô ;ˆ	ð /°·²¸9Ñ1EÔ1EÑEÐEr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r8   Úpropertyr<   r>   r@   r   rH   rS   r#   r   r   r   r      sÈ   € € € € € ðJð JðV 59¸tð /ð /ð /ð /ð /ðbð ð ð( ðð ñ „Xðð
 ðð ñ „Xðð/ð /ð /ðð ð ðð ð ðFð Fð Fð Fð Fr   r   )Úsympy.externalr   Ú$sympy.plotting.backends.base_backendÚplottingÚbackendsrB   Ú__doctest_requires__r   r#   r   r   ú<module>r^      s’   ðà (Ð (Ð (Ð (Ð (Ð (Ø ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;ð �L�>ðÐ ð
lFð lFð lFð lFð lFñ lFô lFð lFð lFð lFr   