
    q-Ph                    f   U d dl mZ d dlZd dlmZmZmZ d dlmZ	 erd dl
Z
d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ e
j        dk    rd dlmZ nd dlmZ e
j        dk    rd dlmZ nd dlmZ eeeeeeef         Zde d<   e!e"ef         Z#de d<    G d d          Z$dS )    )annotationsN)TYPE_CHECKINGCallableUnion)altair)ChannelColor)ChannelOrder)ChannelSize)ChannelTooltip)ChannelX)ChannelY)
EncodeKwds)	DataFrame)   
   )	TypeAlias)r      )Unpackr   Encoding	Encodingsc                  Z    e Zd ZdZddZ	 	 	 dddZ	 	 	 	 dd dZ	 	 	 	 dd!dZeZd"dZ	dS )#DataFramePlotzDataFrame.plot namespace.dfr   returnNonec                8    t          j        |          | _        d S )N)altChart_chart)selfr   s     Y/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/polars/dataframe/plotting.py__init__zDataFramePlot.__init__%   s    imm    NxX | NoneyY | NonecolorColor | NonekwargsUnpack[EncodeKwds]	alt.Chartc                   i }|||d<   |||d<   |||d<    | j                             d          j        di ||                                S )a  
        Draw bar plot.

        Polars does not implement plotting logic itself but instead defers to
        `Altair <https://altair-viz.github.io/>`_.

        `df.plot.bar(**kwargs)` is shorthand for
        `alt.Chart(df).mark_bar().encode(**kwargs).interactive()`,
        and is provided for convenience - for full customisability, use a plotting
        library directly.

        .. versionchanged:: 1.6.0
            In prior versions of Polars, HvPlot was the plotting backend. If you would
            like to restore the previous plotting functionality, all you need to do
            is add `import hvplot.polars` at the top of your script and replace
            `df.plot` with `df.hvplot`.

        Parameters
        ----------
        x
            Column with x-coordinates of bars.
        y
            Column with y-coordinates of bars.
        color
            Column to color bars by.
        **kwargs
            Additional keyword arguments passed to Altair.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     {
        ...         "day": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] * 2,
        ...         "group": ["a"] * 7 + ["b"] * 7,
        ...         "value": [1, 3, 2, 4, 5, 6, 1, 1, 3, 2, 4, 5, 1, 2],
        ...     }
        ... )
        >>> df.plot.bar(
        ...     x="day", y="value", color="day", column="group"
        ... )  # doctest: +SKIP
        Nr$   r&   r(   Ttooltip )r   mark_barencodeinteractive)r    r$   r&   r(   r*   	encodingss         r!   barzDataFramePlot.bar(   s    b  "	=IcN=IcN!&IgDK   ..+ ++#)+ +[]]	
r#   orderOrder | Nonec                   i }|||d<   |||d<   |||d<   |||d<    | j                             d          j        di ||                                S )	a  
        Draw line plot.

        Polars does not implement plotting logic itself but instead defers to
        `Altair <https://altair-viz.github.io/>`_.

        `df.plot.line(**kwargs)` is shorthand for
        `alt.Chart(df).mark_line().encode(**kwargs).interactive()`,
        and is provided for convenience - for full customisatibility, use a plotting
        library directly.

        .. versionchanged:: 1.6.0
            In prior versions of Polars, HvPlot was the plotting backend. If you would
            like to restore the previous plotting functionality, all you need to do
            is add `import hvplot.polars` at the top of your script and replace
            `df.plot` with `df.hvplot`.

        Parameters
        ----------
        x
            Column with x-coordinates of lines.
        y
            Column with y-coordinates of lines.
        color
            Column to color lines by.
        order
            Column to use for order of data points in lines.
        **kwargs
            Additional keyword arguments passed to Altair.

        Examples
        --------
        >>> from datetime import date
        >>> df = pl.DataFrame(
        ...     {
        ...         "date": [date(2020, 1, 2), date(2020, 1, 3), date(2020, 1, 4)] * 2,
        ...         "price": [1, 4, 6, 1, 5, 2],
        ...         "stock": ["a", "a", "a", "b", "b", "b"],
        ...     }
        ... )
        >>> df.plot.line(x="date", y="price", color="stock")  # doctest: +SKIP
        Nr$   r&   r(   r6   Tr.   r0   )r   	mark_liner2   r3   )r    r$   r&   r(   r6   r*   r4   s          r!   linezDataFramePlot.linef   s    f  "	=IcN=IcN!&Ig!&IgDK!!$!//+ ++#)+ +[]]	
r#   sizeSize | Nonec                   i }|||d<   |||d<   |||d<   |||d<    | j                             d          j        di ||                                S )	a  
        Draw scatter plot.

        Polars does not implement plotting logic itself but instead defers to
        `Altair <https://altair-viz.github.io/>`_.

        `df.plot.point(**kwargs)` is shorthand for
        `alt.Chart(df).mark_point().encode(**kwargs).interactive()`,
        and is provided for convenience - for full customisatibility, use a plotting
        library directly.

        .. versionchanged:: 1.6.0
            In prior versions of Polars, HvPlot was the plotting backend. If you would
            like to restore the previous plotting functionality, all you need to do
            is add `import hvplot.polars` at the top of your script and replace
            `df.plot` with `df.hvplot`.

        Parameters
        ----------
        x
            Column with x-coordinates of points.
        y
            Column with y-coordinates of points.
        color
            Column to color points by.
        size
            Column which determines points' sizes.
        **kwargs
            Additional keyword arguments passed to Altair.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     {
        ...         "length": [1, 4, 6],
        ...         "width": [4, 5, 6],
        ...         "species": ["setosa", "setosa", "versicolor"],
        ...     }
        ... )
        >>> df.plot.point(x="length", y="width", color="species")  # doctest: +SKIP
        Nr$   r&   r(   r;   Tr.   r0   )r   
mark_pointr2   r3   )r    r$   r&   r(   r;   r*   r4   s          r!   pointzDataFramePlot.point   s    d  "	=IcN=IcN!&Ig $IfDK""4"00   
 []]	
r#   attrstrCallable[..., alt.Chart]c                    t          | j        d| d           d| d}t          |          dd t          j                  j                                        D             v }|rdfd
}ndfd}|S )Nmark_zAltair has no method 'mark_'r/   c                    h | ]	}|j         
S r0   )name).0values     r!   	<setcomp>z,DataFramePlot.__getattr__.<locals>.<setcomp>   s'     1
 1
 1
 EJ1
 1
 1
r#   r*   r   r   r,   c                 V      d          j         di |                                 S )NTr.   r0   r2   r3   r*   methods    r!   funcz'DataFramePlot.__getattr__.<locals>.func   s5    2vvd+++2<<V<<HHJJJr#   c                 R                  j         di |                                 S )Nr0   rL   rM   s    r!   rO   z'DataFramePlot.__getattr__.<locals>.func   s-    &vvxx0000<<>>>r#   )r*   r   r   r,   )getattrr   AttributeErrorinspect	signature
parametersvalues)r    r@   msgaccepts_tooltip_argumentrO   rN   s        @r!   __getattr__zDataFramePlot.__getattr__   s    ndnnd;;>7777C %%%#, 1
 1
$+$5f$=$=$H$O$O$Q$Q1
 1
 1
 $
  $ 	?K K K K K K K? ? ? ? ? ? r#   )r   r   r   r   )NNN)
r$   r%   r&   r'   r(   r)   r*   r+   r   r,   )NNNN)r$   r%   r&   r'   r(   r)   r6   r7   r*   r+   r   r,   )r$   r%   r&   r'   r(   r)   r;   r<   r*   r+   r   r,   )r@   rA   r   rB   )
__name__
__module____qualname____doc__r"   r5   r:   r?   scatterrY   r0   r#   r!   r   r   "   s        ##$ $ $ $
 "	<
 <
 <
 <
 <
@ ""@
 @
 @
 @
 @
H " B
 B
 B
 B
 B
J G     r#   r   )%
__future__r   rS   typingr   r   r   polars.dependenciesr   r   sysaltair.typingr   Colorr	   Orderr
   Sizer   Tooltipr   Xr   Yr   polarsr   version_infor   typing_extensionsr   r   __annotations__dictrA   r   r   r0   r#   r!   <module>ro      s   " " " " " " "  1 1 1 1 1 1 1 1 1 1 - - - - - - /JJJ333333333333111111777777++++++++++++((((((      
7""$$$$$$$//////
7""!!!!!!!,,,,,,1eUD' ABHBBBBX.I...._ _ _ _ _ _ _ _ _ _r#   