� ��g���N�ddlmZddlmcmcmZddgiZGd�d��ZdS)�)� import_moduleN)�PlotGrid� matplotlibc�j�eZdZdZddd�d�Zd�Zed���Zed���Zd �Z d �Z d �Z d �Z dS) ra� 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�(�tddgd�idtf���|_||_||_g|_d|_||_|D]!}|j�|j���"||_ |r|jr|� ��dSdSdS)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� collectionsz1.1.0)� import_kwargs�min_module_version�catchN) r� RuntimeErrorr�nrows�ncolumns�_series�_fig�args�appendrr)�selfrrrrr�kwargs�args �g/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sympy/plotting/plotgrid.py�__init__zPlotGrid.__init__\s���F(� �%�'F�'F�'F�G�&�|�o�?�?�?����� � �� ��� ��� ��� �� -� -�C� �L� � �� � ,� ,� ,� ,��� � � �D�O� � �I�I�K�K�K�K�K� � � � �c��|jj�|j|j��}i}d}t |j��D]N}t |j��D]7}|t |j��kr|j|||||f<|dz }�8�O|jsind|ji}|jj j di|��|_ |� ��D]o\}}t |j ��dkr|j djrddini}|j j|fi|��} |j |_| |_|����pdS)Nr��figsize� projection�3d�)r�gridspec�GridSpecrr�range�lenrrr �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_figurezPlotGrid._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� � � � � � � �  � rc�F�|js|���|jS�N)rr8�rs r�figz PlotGrid.fig�s&���y� "� � � � !� !� !��y�rc��|Sr:r#r;s r�_backendzPlotGrid._backend�s��� rc�N�|jj�|j��dSr:)rr �closer<r;s rr@zPlotGrid.close�s#�� ���$�$�T�X�.�.�.�.�.rc��tjr9|j���|jj���dS|���dSr:)� base_backend�_showr<� tight_layoutrr rr@r;s rrz PlotGrid.show�sO�� � � � �H� !� !� #� #� #� �O� "� '� '� )� )� )� )� )� �J�J�L�L�L�L�Lrc�:�|j�|��dSr:)r<�savefig)r�paths r�savez PlotGrid.save�s�� ���������rc�n�d�t|j��D��}dd�|��zS)Nc�>�g|]\}}d|zt|��z��S)z Plot[%d]:)�str)�.0r2�plots r� <listcomp>z$PlotGrid.__str__.<locals>.<listcomp>�s;��;�;�;�!�!�T�"�A�o��T���2�;�;�;rzPlotGrid object containing: � )� enumerater�join)r� plot_strss r�__str__zPlotGrid.__str__�sC��;�;�%.�t�y�%9�%9�;�;�;� �/����9�1E�1E�E�Er) �__name__� __module__� __qualname__�__doc__rr8�propertyr<r>r@rrHrSr#rrrrs�������J�J�V59�t�/�/�/�/�/�b���(����X�� ����X��/�/�/�������F�F�F�F�Frr)�sympy.externalr�$sympy.plotting.backends.base_backend�plotting�backendsrB�__doctest_requires__rr#rr�<module>r^s���(�(�(�(�(�(�;�;�;�;�;�;�;�;�;�;�;�;��L�>��� lF�lF�lF�lF�lF�lF�lF�lF�lF�lFr
Memory