
    \h                        S r SSKJr  SSKJr  SSKJr  SSKJrJ	r	  SSK
JrJrJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJrJrJrJrJrJr  SSKJ r J!r!  SSK"J#r#  SSK$J%r%  SSKJ&r&  SSKJ'r'  SSKJ(r(  SSKJ)r)  SSKJ*r*  SSKJ+r+  SSKJ,r,  SSKJ-r-  SSKJ.r.  SSKJ/r/  SSKJ0r0  SSK1J2r2  S/S/S.r3S r4S r5S  r6S! r7S" r8\\S#.r9S$S%.S& jr:S$S%.S' jr;S$S%.S( jr<S) r=S$S%.S* jr>S$S%.S+ jr?S$S%.S, jr@S- rAg.)/a   Plotting 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)DummySymbolWild)import_module)sign)Plot)MatplotlibBackend)TextBackend)LineOver1DRangeSeriesParametric2DLineSeriesParametric3DLineSeriesParametricSurfaceSeriesSurfaceOver2DRangeSeries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))plot3dplot3d_parametric_lineplot3d_parametric_surfaceplot_parametric)plotc                 b   S n[        U5      nUS   n[        SS S /S9n[        UR                  U5      5       Hk  n[        UR                  5      n[	        U5       H+  u  pxUS:  d  M  US   U" US   U 5      U" US   U 5      4Xg'   M-     [        U6 n	UR                  XY5      nMm     X1S'   U$ )	a  Substitute 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                 r    U R                   (       a  U R                  (       a  U $ [        U 5      S:  a  U$ U* $ )Nr   )	is_number	is_finiter   )tbounds     K/var/www/auris/envauris/lib/python3.13/site-packages/sympy/plotting/plot.py	new_bound&_process_summations.<locals>.new_boundZ   s+    H7a<Lv    r   wc                 "    [        U [        5      $ N)
isinstancer   r0   s    r2   <lambda>%_process_summations.<locals>.<lambda>f   s    *Q$r5   c                 L    [        S [        U R                  5       5       5      $ )Nc              3      #    U  H>  u  pUS :  d  M  US   R                   (       + =(       d    US   R                   (       + v   M@     g7f)r         N)r/   ).0ias      r2   	<genexpr>8_process_summations.<locals>.<lambda>.<locals>.<genexpr>g   s>     jO`tqdehidiB1Q4>>)B1Q4>>/ABO`s
   A6A)any	enumerateargsr:   s    r2   r;   r<   g   s    #jyYZY_Y_O`jjr5   )
propertiesr?   r@   )listr
   findrH   rG   r   subs)
	sum_boundrH   r3   exprr6   r0   	sums_argsrB   rC   ss
             r2   _process_summationsrQ   C   s    . :D7D 	S$j 	A
 $))A,L	i(DA1u !!i!i&@adI. 0	 ) Oyy   GKr5   c                      / n[        UR                  SS5      5      nU  HX  nUu  pVpxUR                  5       n	Ub  XS'   [        U5      (       d  [	        U/UQ76 nUR                  [        USS 0 U	D65        MZ     U$ )zKLoop over the provided arguments and create the necessary line series.
    rM   i  Nrendering_kw)intgetcopycallablerQ   appendr   )
rH   kwargsseriesrM   argrN   rlabelrS   kws
             r2   _build_line_seriesr`   v   s     FFJJ{D12I'*$[[]#!-~~~%i6#6C+S"X<<=  Mr5   c                     / nU H;  nUR                  5       nUS   b  US   US'   UR                  U " USS 0 UD65        M=     U$ )zgExtract the rendering_kw dictionary from the provided arguments and
create an appropriate data series.
rT   NrS   )rW   rY   )series_type	plot_exprrZ   r[   rH   r_   s         r2   _create_seriesrd      sY     F[[]8!%bB~k49334	 
 Mr5   c                    [        U[        [        45      (       d  U/n[        U5      S:  a  [        U5      S:X  a  [        U 5      S:  a  U[        U 5      -  n[        U 5      [        U5      :w  a$  [	        S[        U 5       S[        U5       S35      e[        X5       H  u  p4XCl        M     U(       a  [        U[        5      (       a  U/n[        U5      S:X  a  U[        U 5      -  nO<[        U 5      [        U5      :w  a$  [	        S[        U 5       S[        U5       S35      e[        X5       H  u  p5XSl        M     gg)zJApply the `label` and `rendering_kw` keyword arguments to the series.
    r   r?   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)	r9   rJ   tuplelen
ValueErrorzipr^   dictrS   )r[   labelsrS   rP   lr]   s         r2   _set_labelsrm      s9    ftUm,,
6{Qv;!Fa c&k!Fv;#f+% Bv;-0VWF G G 'DAG ( lD))(>L|!CK'L[C-- Ov;-0VWF G G -DAN . r5   c                  J   UR                  SS5      n[        U[        5      (       aB  US:X  a-  [        SS[        4S9nU(       a  [        U 0 UD6$ [        U 0 UD6$ [        U   " U 0 UD6$ [        U5      [        :X  a  [        U[        5      (       a  U" U 0 UD6$ [        S5      e)Nbackenddefaultr&   z1.1.0)min_module_versioncatchz:backend must be either a string or a subclass of ``Plot``.)popr9   strr   RuntimeErrorr   r   plot_backendstype
issubclassr   	TypeError)rH   rZ   ro   r&   s       r2   plot_factoryrz      s    jjI.G'3i&|#*</CJ($9&99///W%t6v66
w-4
Z%>%>'''TUUr5   )r&   textT)showc                    [        U5      n[        USS40 UD6nUR                  SS5      n[        5       nU H@  n[	        US   S   [
        5      (       d  XVS   S   1-  nM+  U[        US   S   5      1-  nMB     U(       a  UR                  UR                  5       5      nU(       a  UR                  5       O
[        S5      nUR                  SU5        UR                  S[        S5      " U5      5        UR                  S	/ 5      nUR                  S
S5      n	[        U0 UD6n
[        XU	5        [        U
0 UD6nU (       a  UR                  5         U$ )a  Plots 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?   paramsNr   xxlabelylabelfr^   rS   )r   r   rV   setr9   rt   r	   
differencekeysrs   
setdefaultr   r`   rm   rz   r|   )r|   rH   rZ   rc   r~   freepr   rk   rS   r[   plotss               r2   r+   r+      s1   z D q!6v6IZZ$'F5D!A$q'3''qT!WIDVAaDG_%%D	 
 v{{}-
sA
h"
ha 01ZZ$F::nd3L5f5F-&+F+E

Lr5   c                     [        U5      n[        USS40 UD6nUR                  S/ 5      nUR                  SS5      n[        [        U40 UD6n[        XdU5        [        U0 UD6nU (       a  UR                  5         U$ )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^   rS   N)r   r   rs   rd   r   rm   rz   r|   r|   rH   rZ   rc   rk   rS   r[   r   s           r2   r*   r*     s~    j D q!6v6IZZ$F::nd3L2IHHF-&+F+E

Lr5   c                 j   [        U5      n[        USS40 UD6nUR                  SS5        UR                  SS5        UR                  SS5        UR                  S	/ 5      nUR                  S
S5      n[	        [
        U40 UD6n[        XdU5        [        U0 UD6nU (       a  UR                  5         U$ )a  
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   yzlabelzr^   rS   N)	r   r   r   rs   rd   r   rm   rz   r|   r   s           r2   r(   r(   j  s    d D q!6v6I
h$
h$
h$ZZ$F::nd3L2IHHF-&+F+E

Lr5   c                    SSK Jn  [        U5      n[        USS40 UD6n[	        5       n[	        5       n[
        U[        [        4nU Hm  nU[        US   S   U5      (       a	  US   S   1O[        US   S   5      1-  nU[        US   S   U5      (       a	  US   S   1O[        US   S   5      1-  nMo     U(       a  UR                  5       O
[        S5      n	U(       a  UR                  5       O
[        S5      n
UR                  SU	5        UR                  SU
5        UR                  S	[        S
5      " X5      5        UR                  SS5      (       a0  [        US   5      (       a  SUS'   [        US   5      (       a  SUS'   UR                  S/ 5      nUR                  SS5      n[        X40 UD6n[        XU5        [!        U0 UD6nUR                  SS5      (       a  UR#                  5         U$ )zRplot3d and plot_contour are structurally identical. Let's reduce
code repetition.
r   )
BaseScalarr?   r@   r   r   r   r   r   r   is_polarF r^   rS   Nr|   T)sympy.vectorr   r   r   r   r	   r   r   r9   rs   r   r   rV   rX   rd   rm   rz   r|   )SeriesrH   rZ   r   rc   free_xfree_y_typesr   r   r   rk   rS   r[   r   s                  r2   _plot3d_plot_contour_helperr     s    (D q!6v6IUFUFj'<8Fz!A$q'6::1Q47)!Q@QQz!A$q'6::1Q47)!Q@QQ  

F3KA

F3KA
h"
h"
ha 34 zz*e$$F8$%%!F8F8$%%!F8ZZ$F::nd3LF88F-&+F+Ezz&$

Lr5   c                 L    UR                  SU 5        [        [        /UQ70 UD6$ )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

r|   )r   r   r   r|   rH   rZ   s      r2   r'   r'     s5    F fd#& 3#'3+13 3r5   c                 j   [        U5      n[        USS40 UD6nUR                  SS5        UR                  SS5        UR                  SS5        UR                  S	/ 5      nUR                  S
S5      n[	        [
        U40 UD6n[        XdU5        [        U0 UD6nU (       a  UR                  5         U$ )a4
  
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

r   r@   r   r   r   r   r   r   r^   rS   N)	r   r   r   rs   rd   r   rm   rz   r|   r   s           r2   r)   r)     s    R D q!6v6I
h$
h$
h$ZZ$F::nd3L3YI&IF-&+F+E

Lr5   c                 L    UR                  SU 5        [        [        /UQ70 UD6$ )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

r|   )r   r   r   r   s      r2   plot_contourr     s*    ` fd#&}FtFvFFr5   c           
         U (       d  / $ US:  Ga`  [        U S   [        5      (       GaG  [        U 5      U:  a  [        S5      e[	        [        U 5      5       H  n[        X   [
        5      (       d  M    O   [        U 5      S-   n[        U SU 6 n[        [        5       R                  " U Vs/ s H  oUR                  PM     sn6 5      n[        U 5      X-   :X  a  U[        XS 6 -   /nU$ [        SS5      n/ n	U H   n
U	R                  [        U
5      U-   5        M"     [	        [        U5      U-
  5       H(  nU	R                  [        [        5       5      U-   5        M*     U[        U	6 -   /nU$ [        U S   [        5      (       d3  [        U S   [
        5      (       Ga   [        U S   5      U:X  Ga  US:w  Ga  [	        [        U 5      5       HU  n[        X   [
        5      (       a  [        X   5      U:w  a    O:[        X   [
        5      (       a  MF  [        X   5      X'   MW     [        U 5      S-   nU SU n[        S U 5       5      (       d   e[        [        5       R                  " U VVs/ s H  nU  H  nUR                  PM     M     snn6 5      n[        U5      U:  a  [        S	U-  5      e[        U 5      X2-   :X  aC  [        X   [
        5      (       a,  [        [        U X3U-    5      6 n	U Vs/ s H  oU	-   PM	     nnU$ [        SS5      n/ n	U H   n
U	R                  [        U
5      U-   5        M"     [	        U[        U5      -
  5       H(  nU	R                  [        [        5       5      U-   5        M*     [        U	6 n	U Vs/ s H  oU	-   PM	     nnU$ [        U S   [
        5      (       a  [        U S   5      X-   :X  a  U  H  n[	        U5       H3  n[        X   [        5      (       a  M  [        S
[        X   5      -  5      e   [	        U5       H3  n[        XU-      5      S:X  a  M  [        S[        XU-      5      -  5      e   M     U $ ggs  snf s  snnf s  snf s  snf )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?   r   z*len(args) should not be less than expr_lenNi
   r   c              3   T   #    U  H  o  H  n[        U[        5      v   M     M      g 7fr8   )r9   r   )rA   rN   es      r2   rD   "check_arguments.<locals>.<genexpr>  s#     G54$Q:a&&$&5s   &(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)r9   r   rg   rh   ranger   rJ   r   unionfree_symbolsrY   r   allrt   )rH   expr_lennb_of_free_symbolsrB   exprsr   r   r   default_rangerangessymbolrN   r\   s                r2   check_argumentsr   k  s3   , 	!|
47D11 t9xIJJs4y!A$'5)) " D	AAtBQx CEKK%)H%Q..%)HIJt955UDO445E  "#rNMF&eFmm;< ' 3|,/AABeEGn}<= CUF^+,E$q'4  ZQ%?%?%(a\X%=%-] s4y!A$'5))c$'lh.Fdgu--.	 " D	AARaG5GGGGGCEKKU *7UT15A +,..15 +9U *7 8 9 |11 24FG H Ht9..:dgu3M3MD!33"5 6 7F/45utF]uE5L "#rNMF&eFmm;< ' -L0AABeEGn}<= CF^F/45utF]uE5L	DGU	#	#DG8U(UC8_!#&$//$%G%([&1 2 2 % -.38|,-2$ &8:=ch,>O:P&Q R R /   )V	#o *I>*7 6 6s   .Q3 Q$;Q*Q/N)B__doc__sympy.concrete.summationsr   sympy.core.containersr   sympy.core.exprr   sympy.core.functionr   r   sympy.core.symbolr   r	   r
   sympy.externalr   sympy.functionsr   $sympy.plotting.backends.base_backendr   )sympy.plotting.backends.matplotlibbackendr   #sympy.plotting.backends.textbackendr   sympy.plotting.seriesr   r   r   r   r   r   sympy.plotting.utilsr   r   sympy.tensor.indexedr   sympy.plotting.plotgridr   r   r   r   r   r   r   r    r!   r"   r#   r$   sympy.plotting.textplotr%   __doctest_requires__rQ   r`   rd   rm   rz   rv   r+   r*   r(   r   r'   r)   r   r    r5   r2   <module>r      s   0 * '   6 3 3 (   5 G ;F F A ( , , 2 2 3 . 3 2 5 & ; F , ' ~ 0f"
@V" $  Tn !% @F (, @F&R  E3P +/ wr " QGhgr5   