
    g                     N    d dl mZ d dlZd dlmZ d dlmZ d Z		 	 	 	 	 	 	 	 ddZ
y)    )NumberN)
graph_objsc                 v    dt        |       dz
  z  }t        |       D cg c]  \  }}||z  |g c}}S c c}}w )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      ?   )len	enumerate)colorsscaleicolors       ^/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/plotly/figure_factory/_2d_density.pymake_linear_colorscaler   	   s<     3v;?#E/8/@A81eQYAAAs   5c
                    | |fD ]3  }
t        d |
D              rt        j                  j                  d       t	        |       t	        |      k7  rt        j                  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                y w)N)
isinstancer   ).0elements     r   	<genexpr>z$create_2d_density.<locals>.<genexpr>a   s     D7:gv.Ds   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widthr'   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_sizer0   r1   r2   arraytrace1trace2trace3trace4r8   r9   figs                     r   create_2d_densityrO      s   X Q DeDD##//I  1vQ++=
 	
 %%j%8J'
3J %%j%8J&&{E:K

+a.z3GF **

F !!
+dA&?tF !!
+dA&?tF FFF+D1d)eeD1d)eeDbzD!9uuED!9uuEF 

f
5CJ    )Earth   r   r   g      ?rS      z2D Density PlotX  rU   )numbersr   plotly.exceptionsr;   plotly.colorsr	   r>   plotly.graph_objsr   r   rO    rP   r   <module>r[      s7       (B 

GrP   