
    ~i                     P    d dl mZ d dlZd dlmZ d dlmZ d Z		 	 	 	 	 	 	 	 ddZ
dS )    )NumberN)
graph_objsc                 d    dt          |           dz
  z  f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                 $    g | ]\  }}|z  |gS  r   ).0icolorscales      U/home/jrussi/.local/lib/python3.11/site-packages/plotly/figure_factory/_2d_density.py
<listcomp>z*make_linear_colorscale.<locals>.<listcomp>   s&    AAA81eQYAAA    )len	enumerate)colorsr   s    @r   make_linear_colorscaler   	   s;     3v;;?#EAAAAy/@/@AAAAr   Earth   r   r   g      ?   2D Density PlotX  c
                    | |fD ]:}
t          d |
D                       st          j                            d          ;t	          |           t	          |          k    rt          j                            d          t          j        |d          }t          |          }t          j        |d          }t          j        |d          }t          j	        | |ddt          |d         |d	          
          }t          j        | |d||dd          }t          j        | dt          |d                   d          }t          j        |dt          |d                   d          }||||g}t          j        dd|||	t          ddgdd          t          ddgdd          t          d          ddt          ddgdd          t          ddgdd                    }t          j        ||          }|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              3   @   K   | ]}t          |t                    V  d S )N)
isinstancer   )r	   elements     r   	<genexpr>z$create_2d_density.<locals>.<genexpr>a   s,      DD7:gv..DDDDDDr   z7All elements of your 'x' and 'y' lists must be numbers.z/Both lists 'x' and 'y' must be the same length.rgbmarkerspointsr   g?)r   sizeopacity)xymodenamemarkerdensityTF)r$   r%   r'   	ncontours
colorscalereversescale	showscalez	x density)r   y2)r$   r'   r(   yaxisz	y densityx2)r%   r'   r(   xaxisg333333?)domainshowgridzeroline2   )tclosestr   )
showlegendautosizetitleheightwidthr1   r/   margin	hovermodebargapxaxis2yaxis2)datalayout)allplotly
exceptionsPlotlyErrorr   clrsvalidate_colorsr   r   ScatterdictHistogram2dContour	HistogramLayoutFigure)r$   r%   r+   r*   
hist_colorpoint_color
point_sizer:   r;   r<   arraytrace1trace2trace3trace4rB   rC   figs                     r   create_2d_densityrY      s\   X Q  DDeDDDDD 	#//I  	 1vvQ++=
 
 	
 %j%88J'
33J %j%88J&{E::K

+a.z3GGG  F *

  F !
+dA&?&?&?t  F !
+dA&?&?&?t  F FFF+D1d)eeDDD1d)eeDDDbzzzD!9uuEEED!9uuEEE  F 
f
5
5
5CJr   )r   r   r   r   r   r   r   r   )numbersr   plotly.exceptionsrE   plotly.colorsr   rH   plotly.graph_objsr   r   rY   r   r   r   <module>r^      s                    ( ( ( ( ( (B B B 

G G G G G Gr   