
    q-Ph                        d dl mZ d dlZd dlmZmZ d dlmZ er.d dl	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 d d	lmZ  G d
 d          ZdS )    )annotationsN)TYPE_CHECKINGCallable)altair)
EncodeKwds)	Encodings)      )Unpack)Seriesc                  >    e Zd ZdZdZddZddZddZddZddZ	dS )
SeriesPlotzSeries.plot namespace.plotsr   returnNonec                Z    |j         pd}|                    |          | _        || _        d S )Nvalue)nameto_frame_df_series_name)selfr   r   s      V/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/polars/series/plotting.py__init__zSeriesPlot.__init__   s/    v ::d##     kwargsUnpack[EncodeKwds]	alt.Chartc                  | j         dk    rd}t          |          t          j        | j          dd          dd} t          j        | j                                      d          j        di ||                                S )	a(  
        Draw histogram.

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

        `s.plot.hist(**kwargs)` is shorthand for
        `alt.Chart(s.to_frame()).mark_bar(tooltip=True).encode(x=alt.X(f'{s.name}:Q', bin=True), y='count()', **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
        ----------
        **kwargs
            Additional arguments and keyword arguments passed to Altair.

        Examples
        --------
        >>> s = pl.Series("price", [1, 3, 3, 3, 5, 2, 6, 5, 5, 5, 7])
        >>> s.plot.hist()  # doctest: +SKIP
        zcount()z6cannot use `plot.hist` when Series name is `'count()'`z:QT)binxytooltip )	r   
ValueErroraltXChartr   mark_barencodeinteractiver   r   msg	encodingss       r   histzSeriesPlot.hist!   s    @ 	))JCS//!$+///T::: 
  
	
CIdhXdX##+ ++#)+ + []]		
r   c               (   | j         dk    rd}t          |          | j         dd} t          j        | j                                      | j         | j         dg                              d          j        di ||                                S )	aI  
        Draw kernel density estimate plot.

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

        `s.plot.kde(**kwargs)` is shorthand for
        `alt.Chart(s.to_frame()).transform_density(s.name, as_=[s.name, 'density']).mark_area(tooltip=True).encode(x=s.name, y='density:Q', **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
        ----------
        **kwargs
            Additional keyword arguments passed to Altair.

        Examples
        --------
        >>> s = pl.Series("price", [1, 3, 3, 3, 5, 2, 6, 5, 5, 5, 7])
        >>> s.plot.kde()  # doctest: +SKIP
        densityz5cannot use `plot.kde` when Series name is `'density'`z	density:Qr"   )as_Tr%   r'   )	r   r(   r)   r+   r   transform_density	mark_arear-   r.   r/   s       r   kdezSeriesPlot.kdeO   s    @ 	))ICS//!%)%6[II	CIdht0t7H)6TUUYtY$$+ +  + $*+ + []]	
r   c               
   | j         dk    rd}t          |          d| j         d} t          j        | 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/>`_.

        `s.plot.line(**kwargs)` is shorthand for
        `alt.Chart(s.to_frame().with_row_index()).mark_line(tooltip=True).encode(x='index', y=s.name, **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
        ----------
        **kwargs
            Additional keyword arguments passed to Altair.

        Examples
        --------
        >>> s = pl.Series("price", [1, 3, 3, 3, 5, 2, 6, 5, 5, 5, 7])
        >>> s.plot.line()  # doctest: +SKIP
        indexz3cannot call `plot.line` when Series name is 'index'r"   Tr%   r'   )	r   r(   r)   r+   r   with_row_index	mark_liner-   r.   r/   s       r   linezSeriesPlot.line{   s    @ ''GCS//!%,43DEE	CIdh--//00YtY$$+ ++#)+ + []]		
r   attrstrCallable[..., alt.Chart]c                   | j         dk    rd| d}t          |          |dk    rd}t          t          j        | j                                                  d| d           d| d}t          |          d| j         d	d
d t          j	                  j
                                        D             v }|rdfd}ndfd}|S )Nr:   zCannot call `plot.z` when Series name is 'index'scatterpointmark_zAltair has no method 'mark_'r"   r&   c                    h | ]	}|j         
S r'   )r   ).0r   s     r   	<setcomp>z)SeriesPlot.__getattr__.<locals>.<setcomp>   s'     1
 1
 1
 EJ1
 1
 1
r   r   r   r   r   c                 Z      d          j         di |                                 S )NTr%   r'   r-   r.   r   r1   methods    r   funcz$SeriesPlot.__getattr__.<locals>.func   s:    2vvd+++2IIYI&IIUUWWWr   c                 V                  j         di |                                 S )Nr'   rJ   rK   s    r   rM   z$SeriesPlot.__getattr__.<locals>.func   s2    &vvxx===f==IIKKKr   )r   r   r   r   )r   r(   getattrr)   r+   r   r;   AttributeErrorinspect	signature
parametersvalues)r   r>   r0   accepts_tooltip_argumentrM   r1   rL   s        @@r   __getattr__zSeriesPlot.__getattr__   sM   ''JtJJJCS//!9D48#:#:#<#<==~t~~tTT>7777C %%%%,43DEE	#, 1
 1
$+$5f$=$=$H$O$O$Q$Q1
 1
 1
 $
  $ 	LX X X X X X X XL L L L L L L r   N)r   r   r   r   )r   r   r   r   )r>   r?   r   r@   )
__name__
__module____qualname____doc__	_accessorr   r2   r8   r=   rV   r'   r   r   r   r      s          I! ! ! !
,
 ,
 ,
 ,
\*
 *
 *
 *
X)
 )
 )
 )
V     r   r   )
__future__r   rQ   typingr   r   polars.dependenciesr   r)   sysaltair.typingr   polars.dataframe.plottingr   version_infor   typing_extensionspolarsr   r   r'   r   r   <module>re      s   " " " " " "  * * * * * * * * - - - - - - JJJ((((((333333
7""!!!!!!!,,,,,,h h h h h h h h h hr   