U
    SZf                     @   sB   d dl mZ d dlZd dlmZ d dlmZ dd Z	dddZ
dS )    )NumberN)
graph_objsc                    s&   dt | d    fddt| D S )z
    Makes a list of colors into a colorscale-acceptable form

    For documentation regarding to the form of the output, see
    https://plot.ly/python/reference/#mesh3d-colorscale
    g      ?   c                    s   g | ]\}}|  |gqS  r   ).0icolorZscaler   E/tmp/pip-unpacked-wheel-5ksk5baj/plotly/figure_factory/_2d_density.py
<listcomp>   s     z*make_linear_colorscale.<locals>.<listcomp>)len	enumerate)colorsr   r	   r
   make_linear_colorscale	   s    r   Earth   r   r   g      ?   2D Density PlotX  c
                 C   sd  | |fD ]"}
t dd |
D stjdqt| t|krHtjdt|d}t|}t|d}t|d}tj	| |ddt
|d |d	d
d}tj| |d||ddd}tj| dt
|d ddd}tj|dt
|d ddd}||||g}tjdd|||	t
ddgdddt
ddgdddt
ddddt
ddgdddt
ddgdddd}tj||d}|S )a=  
    **deprecated**, use instead
    :func:`plotly.express.density_heatmap`.

    :param (list|array) x: x-axis data for plot generation
    :param (list|array) y: y-axis data for plot generation
    :param (str|tuple|list) colorscale: either a plotly scale name, an rgb
        or hex color, a color tuple or a list or tuple of colors. An rgb
        color is of the form 'rgb(x, y, z)' where x, y, z belong to the
        interval [0, 255] and a color tuple is a tuple of the form
        (a, b, c) where a, b and c belong to [0, 1]. If colormap is a
        list, it must contain the valid color types aforementioned as its
        members.
    :param (int) ncontours: the number of 2D contours to draw on the plot
    :param (str) hist_color: the color of the plotted histograms
    :param (str) point_color: the color of the scatter points
    :param (str) point_size: the color of the scatter points
    :param (str) title: set the title for the plot
    :param (float) height: the height of the chart
    :param (float) width: the width of the chart

    Examples
    --------

    Example 1: Simple 2D Density Plot

    >>> from plotly.figure_factory import create_2d_density
    >>> import numpy as np

    >>> # Make data points
    >>> t = np.linspace(-1,1.2,2000)
    >>> x = (t**3)+(0.3*np.random.randn(2000))
    >>> y = (t**6)+(0.3*np.random.randn(2000))

    >>> # Create a figure
    >>> fig = create_2d_density(x, y)

    >>> # Plot the data
    >>> fig.show()

    Example 2: Using Parameters

    >>> from plotly.figure_factory import create_2d_density

    >>> import numpy as np

    >>> # Make data points
    >>> t = np.linspace(-1,1.2,2000)
    >>> x = (t**3)+(0.3*np.random.randn(2000))
    >>> y = (t**6)+(0.3*np.random.randn(2000))

    >>> # Create custom colorscale
    >>> colorscale = ['#7A4579', '#D56073', 'rgb(236,158,105)',
    ...              (1, 1, 0.2), (0.98,0.98,0.98)]

    >>> # Create a figure
    >>> fig = create_2d_density(x, y, colorscale=colorscale,
    ...       hist_color='rgb(255, 237, 222)', point_size=3)

    >>> # Plot the data
    >>> fig.show()
    c                 s   s   | ]}t |tV  qd S )N)
isinstancer   )r   elementr   r   r
   	<genexpr>a   s     z$create_2d_density.<locals>.<genexpr>z7All elements of your 'x' and 'y' lists must be numbers.z/Both lists 'x' and 'y' must be the same length.ZrgbmarkersZpointsr   g?)r   sizeZopacity)xymodenamemarkerZdensityTF)r   r   r   	ncontours
colorscaleZreversescaleZ	showscalez	x density)r   y2)r   r   r   yaxisz	y densityZx2)r   r   r   xaxisg333333?)domainZshowgridZzeroline2   )tZclosestr   )Z
showlegendZautosizetitleheightwidthr$   r#   marginZ	hovermodeZbargapZxaxis2Zyaxis2)datalayout)allplotly
exceptionsZPlotlyErrorr   clrsZvalidate_colorsr   r   ZScatterdictZHistogram2dContourZ	HistogramZLayoutZFigure)r   r   r!   r    Z
hist_colorZpoint_colorZ
point_sizer(   r)   r*   arrayZtrace1Ztrace2Ztrace3Ztrace4r,   r-   Zfigr   r   r
   create_2d_density   st    L	      r4   )r   r   r   r   r   r   r   r   )Znumbersr   Zplotly.exceptionsr/   Zplotly.colorsr   r1   Zplotly.graph_objsr   r   r4   r   r   r   r
   <module>   s           