ó
    Š*£hã  ã                   óF   • S SK Jr  S SKJs  Js  Jr  SS/0r " S S5      rg)é    )Úimport_moduleN)ÚPlotGridÚ
matplotlibc                   óf   • \ rS rSrSrSSS.S jrS r\S 5       r\S	 5       r	S
 r
S rS rS rSrg)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                ó4  • [        SS/ SQ0S[        4S9U l        Xl        X l        / U l        SU l        XPl        U H(  nU R
                  R                  UR
                  5        M*     X@l	        U(       a#  U R                  (       a  U R                  5         ggg)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           ÚT/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/plotting/plotgrid.pyÚ__init__ÚPlotGrid.__init__\   s€   € ôF (¨Ø%Ò'FÐGØ&¬|¨oñ?ˆŒð Œ
Ø ŒØˆŒØˆŒ	ØŒ	ÛˆCØ�L‰L×Ñ §¡Ö,ñ àŒ	Þ�D—O—OØ�I‰I�Kð $ˆ4ó    c                 ó"  • U R                   R                  R                  U R                  U R                  5      n0 nSn[        U R                  5       HR  n[        U R                  5       H6  nU[        U R                  5      :  a  U R                  U   X!XE4   '   US-  nM8     MT     U R                  (       d  0 OSU R                  0nU R                   R                  R                  " S0 UD6U l        UR                  5        H†  u  px[        UR                  5      S:”  a"  UR                  S   R                  (       a  SS0O0 nU R                  R                  " U40 UD6n	U R                  Ul        X˜l        UR%                  5         Mˆ     g )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_figureÚPlotGrid._create_figure�   s6  € Ø�_‰_×%Ñ%×.Ñ.¨t¯z©z¸4¿=¹=ÓIˆØˆØˆÜ�t—z‘zÖ"ˆAÜ˜4Ÿ=™=Ö)�Ø”s˜4Ÿ9™9“~Ó%Ø(,¯	©	°!©�G˜q˜t™HÑ%Ø�Q‘’ó *ñ #ð —y—y‰R y°$·)±)Ð&<ˆØ—O‘O×*Ñ*×1Ò1Ñ7°BÑ7ˆŒ	Ø—}‘}–‰GˆDÜ+.¨q¯y©y«>¸AÓ+=Ø—	‘	˜!‘×"×"ð   Ñ&Ø)+ð à—Y‘Y×*Ò*¨4Ñ6°2Ñ6ˆFØ"Ÿi™iˆAŒOØ#ŒNØ×ÑÖò 'r   c                 ó\   • U R                   (       d  U R                  5         U R                   $ ©N)r   r:   ©r   s    r   ÚfigÚPlotGrid.fig¡   s   € à�y�yØ×ÑÔ!Ø�y‰yÐr   c                 ó   • U $ r=   r%   r>   s    r   Ú_backendÚPlotGrid._backend§   s   € àˆr   c                 ób   • U R                   R                  R                  U R                  5        g r=   )r   r   Úcloser?   r>   s    r   rE   ÚPlotGrid.close«   s   € Ø�‰×Ñ×$Ñ$ T§X¡XÕ.r   c                 óÌ   • [         R                  (       a?  U R                  R                  5         U R                  R
                  R                  5         g U R                  5         g r=   )Úbase_backendÚ_showr?   Útight_layoutr   r   r   rE   r>   s    r   r   ÚPlotGrid.show®   s:   € Ü××Ø�H‰H×!Ñ!Ô#Ø�O‰O×"Ñ"×'Ñ'Õ)à�J‰J�Lr   c                 ó:   • U R                   R                  U5        g r=   )r?   Úsavefig)r   Úpaths     r   ÚsaveÚPlotGrid.saveµ   s   € Ø�‰×Ñ˜Õr   c                 ó¦   • [        U R                  5       VVs/ s H  u  pSU-  [        U5      -   PM     nnnSSR                  U5      -   $ s  snnf )Nz	Plot[%d]:zPlotGrid object containing:
Ú
)Ú	enumerater   ÚstrÚjoin)r   r4   ÚplotÚ	plot_strss       r   Ú__str__ÚPlotGrid.__str__¸   sU   € ä%.¨t¯y©yÔ%9ô;Ú%9™'˜!ð " A‘o¬¨T«Ô2Ù%9ð 	ñ ;ð /°·±¸9Ó1EÑEÐEùó;s   ™A)r   r   r   r   r   r   r	   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r:   Úpropertyr?   rB   rE   r   rO   rX   Ú__static_attributes__r%   r   r   r   r      sX   † ñJðV 59¸tõ /òbð( ñó ðð
 ñó ðò/òòõFr   r   )Úsympy.externalr   Ú$sympy.plotting.backends.base_backendÚplottingÚbackendsrH   Ú__doctest_requires__r   r%   r   r   Ú<module>rf      s-   ðå (ß ;Ó ;ð �L�>ðÐ ÷
lFò lFr   