
    j                    L   U d dl mZ d dlZd dlmZ d dlmZ er}d 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 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ez  ez  ez  ez  ez  Zde d<   e!e"ef         Z#de d<    G d d          Z$dS )    )annotationsN)TYPE_CHECKING)altair)Callable)	TypeAlias)ChannelColor)ChannelOrder)ChannelSize)ChannelTooltip)ChannelX)ChannelY)
EncodeKwds)	DataFrame)      )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     ^/home/longshao/multi-rider-rag/.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&   r4   Tr,   r.   )r   	mark_liner0   r1   )r   r"   r$   r&   r4   r(   r2   s          r   linezDataFramePlot.lined   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&   r9   Tr,   r.   )r   
mark_pointr0   r1   )r   r"   r$   r&   r9   r(   r2   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 r.   )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,   r.   r0   r1   r(   methods    r   funcz'DataFramePlot.__getattr__.<locals>.func   s5    2vvd+++2<<V<<HHJJJr!   c                 R                  j         di |                                 S )Nr.   rJ   rK   s    r   rM   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_argumentrM   rL   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'   r4   r5   r(   r)   r   r*   )r"   r#   r$   r%   r&   r'   r9   r:   r(   r)   r   r*   )r>   r?   r   r@   )
__name__
__module____qualname____doc__r    r3   r8   r=   scatterrW   r.   r!   r   r   r       s        ##$ $ $ $
 "	<
 <
 <
 <
 <
@ ""@
 @
 @
 @
 @
H " B
 B
 B
 B
 B
J G     r!   r   )%
__future__r   rQ   typingr   polars._dependenciesr   r   syscollections.abcr   r   altair.typingr   Colorr	   Orderr
   Sizer   Tooltipr   Xr   Yr   polarsr   version_infor   typing_extensionsr   __annotations__dictr?   r   r   r.   r!   r   <module>rn      s   " " " " " " "              . . . . . . /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""!!!!!!!,,,,,,a%%-%/$6@H@@@@X.I...._ _ _ _ _ _ _ _ _ _r!   