K iFddlmZddlmcmcmZddgiZGddZy)) import_moduleN)PlotGrid matplotlibc\eZdZdZddddZdZedZedZd Z d Z d Z d Z y) 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)showsizec*tddgdidtf|_||_||_g|_d|_||_|D]'}|j j|j )||_ |r|jr|jyyy)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. rfromlist)pyplotcm collectionsz1.1.0) import_kwargsmin_module_versioncatchN) r RuntimeErrorrnrowsncolumns_series_figargsappendrr)selfrrrrrkwargsargs ]/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/plotting/plotgrid.py__init__zPlotGrid.__init__\sF( %'FG&|o?       -C LL   , - DOO IIK$4c|jjj|j|j}i}d}t |jD]P}t |jD]6}|t |jkr|j|||||f<|dz }8R|jsin d|ji}|jjjdi||_ |jD]\}}t |jdkDr|jdjrddini}|jj|fi|} |j|_| |_|j%y)Nrfigsize projection3d)rgridspecGridSpecrrrangelenrrr figureritemsris_3D add_subplot _plotgrid_fig _plotgrid_axprocess_series) rgsmappingcijkwspecpcur_axs r_create_figurezPlotGrid._create_figuresQ __ % % . .tzz4== I tzz" A4==) s499~%(, ! GBq!tH%Q   yyRy$))&<1DOO**117B7 }} GD!+.qyy>A+= ! "" &)+ *TYY**4626F"iiAO#AN     rcR|js|j|jSN)rr8rs rfigz PlotGrid.figsyy    !yyrc|Sr:r#r;s r_backendzPlotGrid._backends rcb|jjj|jyr:)rr closer<r;s rr@zPlotGrid.closes $$TXX.rctjr?|jj|jj j y|jyr:) base_backend_showr< tight_layoutrr rr@r;s rrz PlotGrid.shows:    HH ! ! # OO " " ' ' ) JJLrc:|jj|yr:)r<savefig)rpaths rsavez PlotGrid.saves rct|jDcgc]\}}d|zt|z}}}ddj|zScc}}w)Nz Plot[%d]:zPlotGrid object containing:  ) enumeraterstrjoin)rr2plot plot_strss r__str__zPlotGrid.__str__sT%.tyy%9;!!T"AoT2; ;/91EEE;sA ) __name__ __module__ __qualname____doc__rr8propertyr<r>r@rrHrPr#rrrrsXJV59t/b( /Frr)sympy.externalr$sympy.plotting.backends.base_backendplottingbackendsrB__doctest_requires__rr#rrr[s-(;;L> lFlFr