K idZddlmZddlmZddlmZddlmZm Z ddl m Z m Z m Z ddlmZddlmZdd lmZdd lmZdd lmZdd lmZmZmZmZmZmZdd lm Z m!Z!ddl"m#Z#ddl$m%Z%ddlm&Z&ddlm'Z'ddlm(Z(ddlm)Z)ddlm*Z*ddlm+Z+ddlm,Z,ddlm-Z-ddlm.Z.ddlm/Z/ddlm0Z0ddl1m2Z2dgdgdZ3dZ4dZ5d Z6d!Z7d"Z8eed#Z9d$d%d&Z:d$d%d'Z;d$d%d(Zd$d%d+Z?d$d%d,Z@d-ZAy.)/aPlotting module for SymPy. A plot is represented by the ``Plot`` class that contains a reference to the backend and a list of the data series to be plotted. The data series are instances of classes meant to simplify getting points and meshes from SymPy expressions. ``plot_backends`` is a dictionary with all the backends. This module gives only the essential. For all the fancy stuff use directly the backend. You can get the backend wrapper for every plot from the ``_backend`` attribute. Moreover the data series classes have various useful methods like ``get_points``, ``get_meshes``, etc, that may be useful if you wish to use another plotting library. Especially if you need publication ready graphs and this module is not enough for you - just get the ``_backend`` attribute and add whatever you want directly to it. In the case of matplotlib (the common way to graph data in python) just copy ``_backend.fig`` which is the figure and ``_backend.ax`` which is the axis and work on them as you would on any other matplotlib object. Simplicity of code takes much greater importance than performance. Do not use it if you care at all about performance. A new backend instance is initialized every time you call ``show()`` and the old one is left to the garbage collector. )Sum)Tuple)Expr)Function AppliedUndef)DummySymbolWild) import_module)sign)Plot)MatplotlibBackend) TextBackend)LineOver1DRangeSeriesParametric2DLineSeriesParametric3DLineSeriesParametricSurfaceSeriesSurfaceOver2DRangeSeries ContourSeries)_check_arguments _plot_sympify)Indexed)PlotGrid) BaseSeries)Line2DBaseSeries)Line3DBaseSeries)SurfaceBaseSeries) List2DSeries)GenericDataSeries)centers_of_faces)centers_of_segments)flat) unset_show)_matplotlib_list)textplot matplotlib))plot3dplot3d_parametric_lineplot3d_parametric_surfaceplot_parametric)plotcdd}t|}|d}tdddg}t|j|D]i}t|j}t |D]*\}}|dkDs |d||d|||d|f||<,t |} |j || }k||d<|S) aSubstitute oo (infinity) in the lower/upper bounds of a summation with some integer number. Parameters ========== sum_bound : int oo will be substituted with this integer number. *args : list/tuple pre-processed arguments of the form (expr, range, ...) Notes ===== Let's consider the following summation: ``Sum(1 / x**2, (x, 1, oo))``. The current implementation of lambdify (SymPy 1.12 at the time of writing this) will create something of this form: ``sum(1 / x**2 for x in range(1, INF))`` The problem is that ``type(INF)`` is float, while ``range`` requires integers: the evaluation fails. Instead of modifying ``lambdify`` (which requires a deep knowledge), just replace it with some integer number. c\|jr |jr|St|dk\r|S| S)Nr) is_number is_finiter )tbounds Y/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/plotting/plot.py new_boundz&_process_summations..new_boundZs+  H 7a<Lv rwc"t|tSN) isinstancerr0s r2z%_process_summations..fs *Q$r4cLtdt|jDS)Nc3rK|]/\}}|dkDs |dj xs|dj 1yw)rN)r/).0ias r2 z8_process_summations....gs;jtq!dehidi1Q4>>)B1Q4>>/ABjs 7'7)any enumerateargsr9s r2r:z%_process_summations..gs#jyYZY_Y_O`jjr4) propertiesr=r>)listr findrErDrsubs) sum_boundrEr3exprr5r0 sums_argsr@rAss r2_process_summationsrNCs. :D 7D S$j A $))A, L i( 0DAq1u !!i!i&@adI. 0 !  0 OyyADG Kr4cg}t|jdd}|D]T}|\}}}}|j} ||| d<t|s t |g|}|j t |ddi| V|S)zKLoop over the provided arguments and create the necessary line series. rJiN rendering_kw)intgetcopycallablerNappendr) rEkwargsseriesrJargrKrlabelrPkws r2_build_line_seriesr]vsFFJJ{D12I>'*$a [[]  #!-B~ ~%i6#6C +S"X<<=> Mr4c g}|D]9}|j}|d|d|d<|j||ddi|;|S)zoExtract the rendering_kw dictionary from the provided arguments and create an appropriate data series. rQNrP)rTrV) series_type plot_exprrWrXrEr\s r2_create_seriesras^F5 [[] 8 !%bB~  k49334 5 Mr4cdt|ttfs|g}t|dkDrt|dk(rt|dkDr|t|z}t|t|k7r$t dt|dt|dt ||D] \}}||_|rt|tr|g}t|dk(r|t|z}n;t|t|k7r$t dt|dt|dt ||D] \}}||_yy)zJApply the `label` and `rendering_kw` keyword arguments to the series. rr=zXThe number of labels must be equal to the number of expressions being plotted. Received z expressions and z labelszhThe number of rendering dictionaries must be equal to the number of expressions being plotted. Received N) r8rGtuplelen ValueErrorzipr[dictrP)rXlabelsrPrMlrZs r2 _set_labelsrjsI ftUm , 6{Q v;! F a c&k !F v;#f+ %Bv;-0V WFG G' DAqAG  lD )(>L |  ! CK 'L [C - -Ov;-0V WFG G - DAqAN r4c,|jdd}t|tr>|dk(r+tddtf}|r t |i|St |i|St||i|St|tk(rt|tr||i|Std)Nbackenddefaultr&z1.1.0)min_module_versioncatchz:backend must be either a string or a subclass of ``Plot``.) popr8strr RuntimeErrorrr plot_backendstype issubclassr TypeError)rErWrlr&s r2 plot_factoryrwsjjI.G'3 i &|#*'''TUUr4)r&textT)showct|}t|ddfi|}|jdd}t}|D]:}t |ddt s ||ddhz}&|t |ddhz}<|r|j|j}|r|jn t d}|jd||jdtd||jd g}|jd d} t|i|} t| || t| i|} |r| j| S) aPlots a function of a single variable as a curve. Parameters ========== args : The first argument is the expression representing the function of single variable to be plotted. The last argument is a 3-tuple denoting the range of the free variable. e.g. ``(x, 0, 5)`` Typical usage examples are in the following: - Plotting a single expression with a single range. ``plot(expr, range, **kwargs)`` - Plotting a single expression with the default range (-10, 10). ``plot(expr, **kwargs)`` - Plotting multiple expressions with a single range. ``plot(expr1, expr2, ..., range, **kwargs)`` - Plotting multiple expressions with multiple ranges. ``plot((expr1, range1), (expr2, range2), ..., **kwargs)`` It is best practice to specify range explicitly because default range may change in the future if a more advanced default range detection algorithm is implemented. show : bool, optional The default value is set to ``True``. Set show to ``False`` and the function will not display the plot. The returned instance of the ``Plot`` class can then be used to save or display the plot by calling the ``save()`` and ``show()`` methods respectively. line_color : string, or float, or function, optional Specifies the color for the plot. See ``Plot`` to see how to set color for the plots. Note that by setting ``line_color``, it would be applied simultaneously to all the series. title : str, optional Title of the plot. It is set to the latex representation of the expression, if the plot has only one expression. label : str, optional The label of the expression in the plot. It will be used when called with ``legend``. Default is the name of the expression. e.g. ``sin(x)`` xlabel : str or expression, optional Label for the x-axis. ylabel : str or expression, optional Label for the y-axis. xscale : 'linear' or 'log', optional Sets the scaling of the x-axis. yscale : 'linear' or 'log', optional Sets the scaling of the y-axis. axis_center : (float, float), optional Tuple of two floats denoting the coordinates of the center or {'center', 'auto'} xlim : (float, float), optional Denotes the x-axis limits, ``(min, max)```. ylim : (float, float), optional Denotes the y-axis limits, ``(min, max)```. annotations : list, optional A list of dictionaries specifying the type of annotation required. The keys in the dictionary should be equivalent to the arguments of the :external:mod:`matplotlib`'s :external:meth:`~matplotlib.axes.Axes.annotate` method. markers : list, optional A list of dictionaries specifying the type the markers required. The keys in the dictionary should be equivalent to the arguments of the :external:mod:`matplotlib`'s :external:func:`~matplotlib.pyplot.plot()` function along with the marker related keyworded arguments. rectangles : list, optional A list of dictionaries specifying the dimensions of the rectangles to be plotted. The keys in the dictionary should be equivalent to the arguments of the :external:mod:`matplotlib`'s :external:class:`~matplotlib.patches.Rectangle` class. fill : dict, optional A dictionary specifying the type of color filling required in the plot. The keys in the dictionary should be equivalent to the arguments of the :external:mod:`matplotlib`'s :external:meth:`~matplotlib.axes.Axes.fill_between` method. adaptive : bool, optional The default value for the ``adaptive`` parameter is now ``False``. To enable adaptive sampling, set ``adaptive=True`` and specify ``n`` if uniform sampling is required. The plotting uses an adaptive algorithm which samples recursively to accurately plot. The adaptive algorithm uses a random point near the midpoint of two points that has to be further sampled. Hence the same plots can appear slightly different. depth : int, optional Recursion depth of the adaptive algorithm. A depth of value `n` samples a maximum of `2^{n}` points. If the ``adaptive`` flag is set to ``False``, this will be ignored. n : int, optional Used when the ``adaptive`` is set to ``False``. The function is uniformly sampled at ``n`` number of points. If the ``adaptive`` flag is set to ``True``, this will be ignored. This keyword argument replaces ``nb_of_points``, which should be considered deprecated. 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. Examples ======== .. plot:: :context: close-figs :format: doctest :include-source: True >>> from sympy import symbols >>> from sympy.plotting import plot >>> x = symbols('x') Single Plot .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot(x**2, (x, -5, 5)) Plot object containing: [0]: cartesian line: x**2 for x over (-5.0, 5.0) Multiple plots with single range. .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot(x, x**2, x**3, (x, -5, 5)) 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) Multiple plots with different ranges. .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot((x**2, (x, -6, 6)), (x, (x, -5, 5))) 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) No adaptive sampling by default. If adaptive sampling is required, set ``adaptive=True``. .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot(x**2, adaptive=True, n=400) Plot object containing: [0]: cartesian line: x**2 for x over (-10.0, 10.0) See Also ======== Plot, LineOver1DRangeSeries r=paramsNrxxlabelylabelfr[rP)rrrSsetr8rqr differencekeysrp setdefaultrr]rjrwry) ryrErWr`r{freepr|rhrPrXplotss r2r+r+s9z  D q!6v6I ZZ$ 'F 5D &!A$q'3' QqT!WI D VAaDG_% %D & v{{}- s A h" h  a 01 ZZ $F::nd3L  5f 5F - & +F +E  Lr4ct|}t|ddfi|}|jdg}|jdd}tt|fi|}t |||t |i|}|r|j|S)a Plots a 2D parametric curve. Parameters ========== args Common specifications are: - Plotting a single parametric curve with a range ``plot_parametric((expr_x, expr_y), range)`` - Plotting multiple parametric curves with the same range ``plot_parametric((expr_x, expr_y), ..., range)`` - Plotting multiple parametric curves with different ranges ``plot_parametric((expr_x, expr_y, range), ...)`` ``expr_x`` is the expression representing $x$ component of the parametric function. ``expr_y`` is the expression representing $y$ component of the parametric function. ``range`` is a 3-tuple denoting the parameter symbol, start and stop. For example, ``(u, 0, 5)``. If the range is not specified, then a default range of (-10, 10) is used. However, if the arguments are specified as ``(expr_x, expr_y, range), ...``, you must specify the ranges for each expressions manually. Default range may change in the future if a more advanced algorithm is implemented. adaptive : bool, optional Specifies whether to use the adaptive sampling or not. The default value is set to ``True``. Set adaptive to ``False`` and specify ``n`` if uniform sampling is required. depth : int, optional The recursion depth of the adaptive algorithm. A depth of value $n$ samples a maximum of $2^n$ points. n : int, optional Used when the ``adaptive`` flag is set to ``False``. Specifies the number of the points used for the uniform sampling. This keyword argument replaces ``nb_of_points``, which should be considered deprecated. line_color : string, or float, or function, optional Specifies the color for the plot. See ``Plot`` to see how to set color for the plots. Note that by setting ``line_color``, it would be applied simultaneously to all the series. label : str, optional The label of the expression in the plot. It will be used when called with ``legend``. Default is the name of the expression. e.g. ``sin(x)`` xlabel : str, optional Label for the x-axis. ylabel : str, optional Label for the y-axis. xscale : 'linear' or 'log', optional Sets the scaling of the x-axis. yscale : 'linear' or 'log', optional Sets the scaling of the y-axis. axis_center : (float, float), optional Tuple of two floats denoting the coordinates of the center or {'center', 'auto'} xlim : (float, float), optional Denotes the x-axis limits, ``(min, max)```. ylim : (float, float), optional Denotes the y-axis limits, ``(min, max)```. 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. Examples ======== .. plot:: :context: reset :format: doctest :include-source: True >>> from sympy import plot_parametric, symbols, cos, sin >>> u = symbols('u') A parametric plot with a single expression: .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot_parametric((cos(u), sin(u)), (u, -5, 5)) Plot object containing: [0]: parametric cartesian line: (cos(u), sin(u)) for u over (-5.0, 5.0) A parametric plot with multiple expressions with the same range: .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot_parametric((cos(u), sin(u)), (u, cos(u)), (u, -10, 10)) Plot object containing: [0]: parametric cartesian line: (cos(u), sin(u)) for u over (-10.0, 10.0) [1]: parametric cartesian line: (u, cos(u)) for u over (-10.0, 10.0) A parametric plot with multiple expressions with different ranges for each curve: .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot_parametric((cos(u), sin(u), (u, -5, 5)), ... (cos(u), u, (u, -5, 5))) Plot object containing: [0]: parametric cartesian line: (cos(u), sin(u)) for u over (-5.0, 5.0) [1]: parametric cartesian line: (cos(u), u) for u over (-5.0, 5.0) Notes ===== The plotting uses an adaptive algorithm which samples recursively to accurately plot the curve. The adaptive algorithm uses a random point near the midpoint of two points that has to be further sampled. Hence, repeating the same plot command can give slightly different results because of the random sampling. If there are multiple plots, then the same optional arguments are applied to all the plots drawn in the same canvas. If you want to set these options separately, you can index the returned ``Plot`` object and set it. For example, when you specify ``line_color`` once, it would be applied simultaneously to both series. .. plot:: :context: close-figs :format: doctest :include-source: True >>> from sympy import pi >>> expr1 = (u, cos(2*pi*u)/2 + 1/2) >>> expr2 = (u, sin(2*pi*u)/2 + 1/2) >>> p = plot_parametric(expr1, expr2, (u, 0, 1), line_color='blue') If you want to specify the line color for the specific series, you should index each item and apply the property manually. .. plot:: :context: close-figs :format: doctest :include-source: True >>> p[0].line_color = 'red' >>> p.show() See Also ======== Plot, Parametric2DLineSeries r>r=r[rPN)rrrprarrjrwryryrErWr`rhrPrXrs r2r*r*sj  D q!6v6I ZZ $F::nd3L 2I H HF - & +F +E  Lr4cbt|}t|ddfi|}|jdd|jdd|jdd|jd g}|jd d }t t |fi|}t |||t|i|}|r|j|S) aB Plots a 3D parametric line plot. Usage ===== Single plot: ``plot3d_parametric_line(expr_x, expr_y, expr_z, range, **kwargs)`` If the range is not specified, then a default range of (-10, 10) is used. Multiple plots. ``plot3d_parametric_line((expr_x, expr_y, expr_z, range), ..., **kwargs)`` Ranges have to be specified for every expression. Default range may change in the future if a more advanced default range detection algorithm is implemented. Arguments ========= expr_x : Expression representing the function along x. expr_y : Expression representing the function along y. expr_z : Expression representing the function along z. range : (:class:`~.Symbol`, float, float) A 3-tuple denoting the range of the parameter variable, e.g., (u, 0, 5). Keyword Arguments ================= Arguments for ``Parametric3DLineSeries`` class. n : int The range is uniformly sampled at ``n`` number of points. This keyword argument replaces ``nb_of_points``, which should be considered deprecated. Aesthetics: line_color : string, or float, or function, optional Specifies the color for the plot. See ``Plot`` to see how to set color for the plots. Note that by setting ``line_color``, it would be applied simultaneously to all the series. label : str The label to the plot. It will be used when called with ``legend=True`` to denote the function with the given label in the plot. If there are multiple plots, then the same series arguments are applied to all the plots. If you want to set these options separately, you can index the returned ``Plot`` object and set it. Arguments for ``Plot`` class. title : str Title of the plot. 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. Examples ======== .. plot:: :context: reset :format: doctest :include-source: True >>> from sympy import symbols, cos, sin >>> from sympy.plotting import plot3d_parametric_line >>> u = symbols('u') Single plot. .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot3d_parametric_line(cos(u), sin(u), u, (u, -5, 5)) Plot object containing: [0]: 3D parametric cartesian line: (cos(u), sin(u), u) for u over (-5.0, 5.0) Multiple plots. .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot3d_parametric_line((cos(u), sin(u), u, (u, -5, 5)), ... (sin(u), u**2, u, (u, -5, 5))) Plot object containing: [0]: 3D parametric cartesian line: (cos(u), sin(u), u) for u over (-5.0, 5.0) [1]: 3D parametric cartesian line: (sin(u), u**2, u) for u over (-5.0, 5.0) See Also ======== Plot, Parametric3DLineSeries r=r}r|r~yzlabelzr[rPN) rrrrprarrjrwryrs r2r(r(jsd  D q!6v6I h$ h$ h$ ZZ $F::nd3L 2I H HF - & +F +E  Lr4cddlm}t|}t|ddfi|}t }t }t |t tf}|D]b}|t|dd|r |ddhnt |ddhz}|t|dd|r |ddhnt |ddhz}d|r|jn t d} |r|jn t d} |jd| |jd| |jd td | | |jd d r&t|drd |d<t|drd |d<|jdg} |jdd} t||fi|} t| | | t!| i|}|jddr|j#|S)zZplot3d and plot_contour are structurally identical. Let's reduce code repetition. r) BaseScalarr=r>r|rr}r~rris_polarFr[rPNryT) sympy.vectorrrrrr rrr8rprrrSrUrarjrwry)SeriesrErWrr`free_xfree_y_typesrr|rrhrPrXrs r2_plot3d_plot_contour_helperrs (  D q!6v6I UF UFj'< 8F Rz!A$q'6:1Q47)!Q@QQz!A$q'6:1Q47)!Q@QQR F3KA F3KA h" h" h  a 34zz*e$ F8$ %!F8  F8$ %!F8  ZZ $F::nd3L FI 8 8F - & +F +E zz&$ Lr4cL|jd|ttg|i|S)a Plots a 3D surface plot. Usage ===== Single plot ``plot3d(expr, range_x, range_y, **kwargs)`` If the ranges are not specified, then a default range of (-10, 10) is used. Multiple plot with the same range. ``plot3d(expr1, expr2, range_x, range_y, **kwargs)`` If the ranges are not specified, then a default range of (-10, 10) is used. Multiple plots with different ranges. ``plot3d((expr1, range_x, range_y), (expr2, range_x, range_y), ..., **kwargs)`` Ranges have to be specified for every expression. Default range may change in the future if a more advanced default range detection algorithm is implemented. Arguments ========= expr : Expression representing the function along x. range_x : (:class:`~.Symbol`, float, float) A 3-tuple denoting the range of the x variable, e.g. (x, 0, 5). range_y : (:class:`~.Symbol`, float, float) A 3-tuple denoting the range of the y variable, e.g. (y, 0, 5). Keyword Arguments ================= Arguments for ``SurfaceOver2DRangeSeries`` class: n1 : int The x range is sampled uniformly at ``n1`` of points. This keyword argument replaces ``nb_of_points_x``, which should be considered deprecated. n2 : int The y range is sampled uniformly at ``n2`` of points. This keyword argument replaces ``nb_of_points_y``, which should be considered deprecated. Aesthetics: surface_color : Function which returns a float Specifies the color for the surface of the plot. See :class:`~.Plot` for more details. If there are multiple plots, then the same series arguments are applied to all the plots. If you want to set these options separately, you can index the returned ``Plot`` object and set it. Arguments for ``Plot`` class: title : str Title of the plot. 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. Examples ======== .. plot:: :context: reset :format: doctest :include-source: True >>> from sympy import symbols >>> from sympy.plotting import plot3d >>> x, y = symbols('x y') Single plot .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot3d(x*y, (x, -5, 5), (y, -5, 5)) Plot object containing: [0]: cartesian surface: x*y for x over (-5.0, 5.0) and y over (-5.0, 5.0) Multiple plots with same range .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot3d(x*y, -x*y, (x, -5, 5), (y, -5, 5)) Plot object containing: [0]: cartesian surface: x*y for x over (-5.0, 5.0) and y over (-5.0, 5.0) [1]: cartesian surface: -x*y for x over (-5.0, 5.0) and y over (-5.0, 5.0) Multiple plots with different ranges. .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot3d((x**2 + y**2, (x, -5, 5), (y, -5, 5)), ... (x*y, (x, -3, 3), (y, -3, 3))) Plot object containing: [0]: cartesian surface: x**2 + y**2 for x over (-5.0, 5.0) and y over (-5.0, 5.0) [1]: cartesian surface: x*y for x over (-3.0, 3.0) and y over (-3.0, 3.0) See Also ======== Plot, SurfaceOver2DRangeSeries ry)rrrryrErWs r2r'r's5F fd# &  3#' 3+1 33r4cbt|}t|ddfi|}|jdd|jdd|jdd|jd g}|jd d }t t |fi|}t |||t|i|}|r|j|S) a@ Plots a 3D parametric surface plot. Explanation =========== Single plot. ``plot3d_parametric_surface(expr_x, expr_y, expr_z, range_u, range_v, **kwargs)`` If the ranges is not specified, then a default range of (-10, 10) is used. Multiple plots. ``plot3d_parametric_surface((expr_x, expr_y, expr_z, range_u, range_v), ..., **kwargs)`` Ranges have to be specified for every expression. Default range may change in the future if a more advanced default range detection algorithm is implemented. Arguments ========= expr_x : Expression representing the function along ``x``. expr_y : Expression representing the function along ``y``. expr_z : Expression representing the function along ``z``. range_u : (:class:`~.Symbol`, float, float) A 3-tuple denoting the range of the u variable, e.g. (u, 0, 5). range_v : (:class:`~.Symbol`, float, float) A 3-tuple denoting the range of the v variable, e.g. (v, 0, 5). Keyword Arguments ================= Arguments for ``ParametricSurfaceSeries`` class: n1 : int The ``u`` range is sampled uniformly at ``n1`` of points. This keyword argument replaces ``nb_of_points_u``, which should be considered deprecated. n2 : int The ``v`` range is sampled uniformly at ``n2`` of points. This keyword argument replaces ``nb_of_points_v``, which should be considered deprecated. Aesthetics: surface_color : Function which returns a float Specifies the color for the surface of the plot. See :class:`~Plot` for more details. If there are multiple plots, then the same series arguments are applied for all the plots. If you want to set these options separately, you can index the returned ``Plot`` object and set it. Arguments for ``Plot`` class: title : str Title of the plot. 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. Examples ======== .. plot:: :context: reset :format: doctest :include-source: True >>> from sympy import symbols, cos, sin >>> from sympy.plotting import plot3d_parametric_surface >>> u, v = symbols('u v') Single plot. .. plot:: :context: close-figs :format: doctest :include-source: True >>> plot3d_parametric_surface(cos(u + v), sin(u - v), u - v, ... (u, -5, 5), (v, -5, 5)) Plot object containing: [0]: parametric cartesian surface: (cos(u + v), sin(u - v), u - v) for u over (-5.0, 5.0) and v over (-5.0, 5.0) See Also ======== Plot, ParametricSurfaceSeries rr>r}r|r~rrrr[rPN) rrrrprarrjrwryrs r2r)r)sR  D q!6v6I h$ h$ h$ ZZ $F::nd3L 3Y I& IF - & +F +E  Lr4cL|jd|ttg|i|S)a Draws contour plot of a function Usage ===== Single plot ``plot_contour(expr, range_x, range_y, **kwargs)`` If the ranges are not specified, then a default range of (-10, 10) is used. Multiple plot with the same range. ``plot_contour(expr1, expr2, range_x, range_y, **kwargs)`` If the ranges are not specified, then a default range of (-10, 10) is used. Multiple plots with different ranges. ``plot_contour((expr1, range_x, range_y), (expr2, range_x, range_y), ..., **kwargs)`` Ranges have to be specified for every expression. Default range may change in the future if a more advanced default range detection algorithm is implemented. Arguments ========= expr : Expression representing the function along x. range_x : (:class:`Symbol`, float, float) A 3-tuple denoting the range of the x variable, e.g. (x, 0, 5). range_y : (:class:`Symbol`, float, float) A 3-tuple denoting the range of the y variable, e.g. (y, 0, 5). Keyword Arguments ================= Arguments for ``ContourSeries`` class: n1 : int The x range is sampled uniformly at ``n1`` of points. This keyword argument replaces ``nb_of_points_x``, which should be considered deprecated. n2 : int The y range is sampled uniformly at ``n2`` of points. This keyword argument replaces ``nb_of_points_y``, which should be considered deprecated. Aesthetics: surface_color : Function which returns a float Specifies the color for the surface of the plot. See :class:`sympy.plotting.Plot` for more details. If there are multiple plots, then the same series arguments are applied to all the plots. If you want to set these options separately, you can index the returned ``Plot`` object and set it. Arguments for ``Plot`` class: title : str Title of the plot. 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. See Also ======== Plot, ContourSeries ry)rrrrs r2 plot_contourrs*` fd# &} Ft Fv FFr4c H|sgS|dkDrOt|dtr;t||kr tdt t|D]}t||t snt|dz}t |d|}t tj|Dcgc]}|jc}}t|||zk(r|t ||dzg}|St dd}g} |D]} | jt | |z!t t||z D]'}| jt t|z)|t | zg}|St|dts,t|dt rt|d|k(r|dk7rt t|D]M}t||t rt|||k7rn5t||t r=t ||||<Ot|dz}|d|}td|DsJt tj|D cgc]} | D]}|jc}} }t||kDrtd |zt|||zk(r>t||t r+t t ||||z} |D cgc]} | | z }} |St dd}g} |D]} | jt | |z!t |t|z D]'}| jt t|z)t | } |D cgc]} | | z }} |St|dt rt|d||zk(r|D]} t |D]/}t| |trtd t| |zt |D]3}t| ||zdk(rtd t| ||zz|Syycc}wcc}} wcc} wcc} w) a Checks the arguments and converts into tuples of the form (exprs, ranges). Examples ======== .. plot:: :context: reset :format: doctest :include-source: True >>> from sympy import cos, sin, symbols >>> from sympy.plotting.plot import check_arguments >>> x = symbols('x') >>> check_arguments([cos(x), sin(x)], 2, 1) [(cos(x), sin(x), (x, -10, 10))] >>> check_arguments([x, x**2], 1, 1) [(x, (x, -10, 10)), (x**2, (x, -10, 10))] r=rz*len(args) should not be less than expr_lenNi rc3JK|]}|D]}t|tywr7)r8r)r?rKes r2rBz"check_arguments..s$G4$GQ:a&G&Gs!#z?The number of free_symbols in the expression is greater than %dz Expected an expression, given %sz0The ranges should be a tuple of length 3, got %s)r8rrdrerangerrGrunion free_symbolsrVrallrq) rEexpr_lennb_of_free_symbolsr@exprsrrr default_rangerangessymbolrKrYs r2check_argumentsrksl,  !| 47D1 t9x IJ Js4y! A$q'5) D A AtBQx KCEKK%)HQ!..)HIJ t9#55 5UDO445E "#rNMF& = eFmm;< =3|,/AAB > eEGn}<= >UF^+,E $q'4 ZQ%?%(a\X%=%-]s4y! A$q'5)c$q'lh.Fd1gu-Q.Q   D A ARaG5GGGGKCEKKU*7T15*7,-+,..*7.*789  | 1 124FGH H t9.. .:d1gu3MDQ!33"567F/45tTF]5E5L"#rNMF& = eFmm;< =-L0AAB > eEGn}<= >F^F/45tTF]5E5L DGU #DG CU8U(U RC8_ 2!#a&$/$%G%(Q[&122 2-. R3q8|,-2$&8:=c!h,>O:P&QRR R  R )V #o*I>*766sP P P PN)B__doc__sympy.concrete.summationsrsympy.core.containersrsympy.core.exprrsympy.core.functionrrsympy.core.symbolrr r sympy.externalr sympy.functionsr $sympy.plotting.backends.base_backendr )sympy.plotting.backends.matplotlibbackendr#sympy.plotting.backends.textbackendrsympy.plotting.seriesrrrrrrsympy.plotting.utilsrrsympy.tensor.indexedrsympy.plotting.plotgridrrrrrrrr r!r"r#r$sympy.plotting.textplotr%__doctest_requires__rNr]rarjrwrsr+r*r(rr'r)rrr4r2rs0*' 633( 5G;FFA(,,223.325&;F,'~0f" @ V"$  Tn!%@F(,@F&RE3P+/wr"QGhgr4