
    6Dhq(                         S SK Jr  S SKJrJr  S SKJr  S SKJ	r	  S SK
Jr  \R                  " S5      rS r       SS jrS	 rS
 r " S S\5      rg)    N)
exceptionsoptional_imports)utils)
graph_objs)ColorscaleValidatornumpyc                    Ubx  [        U[        5      (       ac  [        R                  " X5        [	        [        U 5      5       H5  n[        X   5      [        X4   5      :w  d  M!  [        R                  " S5      e   U(       a1  [        U5      [        U S   5      :w  a  [        R                  " S5      eU(       a/  [        U5      [        U 5      :w  a  [        R                  " S5      egg)a  
Annotated-heatmap-specific validations

Check that if a text matrix is supplied, it has the same
dimensions as the z matrix.

See FigureFactory.create_annotated_heatmap() for params

:raises: (PlotlyError) If z and text matrices do not  have the same
    dimensions.
Nz*z and text should have the same dimensionsr   zMoops, the x list that you provided does not match the width of your z matrix zNoops, the y list that you provided does not match the length of your z matrix )
isinstancelistr   validate_equal_lengthrangelenr   PlotlyError)zxyannotation_textlsts        Z/var/www/html/env/lib/python3.13/site-packages/plotly/figure_factory/_annotated_heatmap.pyvalidate_annotated_heatmapr      s     "z/4'H'H##A7Q=C16{c/"677 ,,C  ! 	q6S1Y((*  	q6SV((+   	    c                    Ub  UO/ n[        XX#5        [        5       n	U	R                  U5      n[        XX#XEU40 UD6R	                  5       n
U(       d  U(       a2  [        SSU UUUUUS.UD6n[        U
[        SSSSS9[        SSSS	9S
9nO/[        SSU UUUS.UD6n[        U
[        SSSSS9[        SSSS9S
9nU/n[        R                  " XS9$ )a1  
**deprecated**, use instead
:func:`plotly.express.imshow`.

Function that creates annotated heatmaps

This function adds annotations to each cell of the heatmap.

:param (list[list]|ndarray) z: z matrix to create heatmap.
:param (list) x: x axis labels.
:param (list) y: y axis labels.
:param (list[list]|ndarray) annotation_text: Text strings for
    annotations. Should have the same dimensions as the z matrix. If no
    text is added, the values of the z matrix are annotated. Default =
    z matrix values.
:param (list|str) colorscale: heatmap colorscale.
:param (list) font_colors: List of two color strings: [min_text_color,
    max_text_color] where min_text_color is applied to annotations for
    heatmap values < (max_value - min_value)/2. If font_colors is not
    defined, the colors are defined logically as black or white
    depending on the heatmap's colorscale.
:param (bool) showscale: Display colorscale. Default = False
:param (bool) reversescale: Reverse colorscale. Default = False
:param kwargs: kwargs passed through plotly.graph_objs.Heatmap.
    These kwargs describe other attributes about the annotated Heatmap
    trace such as the colorscale. For more information on valid kwargs
    call help(plotly.graph_objs.Heatmap)

Example 1: Simple annotated heatmap with default configuration

>>> import plotly.figure_factory as ff

>>> z = [[0.300000, 0.00000, 0.65, 0.300000],
...      [1, 0.100005, 0.45, 0.4300],
...      [0.300000, 0.00000, 0.65, 0.300000],
...      [1, 0.100005, 0.45, 0.00000]]

>>> fig = ff.create_annotated_heatmap(z)
>>> fig.show()
heatmap)typer   r   r   
colorscale	showscalereversescale    topzrgb(0, 0, 0))ticksdtickside	gridcolorz  )r!   r"   
ticksuffix)annotationsxaxisyaxis)r   r   r   r   r   F)r!   r#   r$   showticklabels)r!   r%   r)   )datalayout )r   r   validate_coerce_AnnotatedHeatmapmake_annotationsdictr   Figure)r   r   r   r   r   font_colorsr   r   kwargscolorscale_validatorr&   tracer+   r*   s                 r   create_annotated_heatmapr6   0   s-   j "-!8+bKqQ8 /0%55jAJ#	a*<KQ  	A 	
!%	
 	
 #RquORqT:
  
!%
 
 #uu RDG
 7D$66r   c                 (   U R                  5       n U R                  S5      (       a:  U R                  S5      R                  S5       Vs/ s H  n[        U5      PM     sn$ U R                  S5      (       a  [        R
                  " U 5      $ U$ s  snf )Nrgbzrgba(),#)strip
startswithsplitintclrs
hex_to_rgb)	color_strdefaultvs      r   to_rgb_color_listrD      sy    !IE"" ) 9 ? ? DE D1A DEE			c	"	"y))	 Fs   	Bc                 <    U S   S-  U S   S-  -   U S   S-  -   S:  $ )Nr   gA`"?r   gbX9?   gv/?   r,   )background_colors    r   should_use_black_textrI      sB    e#
1

%	&
1

%	& 		 r   c                   *    \ rS rSrSrS rS rS rSrg)r.      z@
Refer to TraceFactory.create_annotated_heatmap() for docstring
c                    Xl         U(       a  X l        O[        [        US   5      5      U l        U(       a  X0l        O[        [        U5      5      U l        Ub  X@l        OU R                   U l        XPl        Xpl        X`l        [        (       ar  [        U R                   [        R                  5      (       aI  [        R                  U R                   5      U l        [        R                  U R                   5      U l        Oj[!        U R                    V	V
s/ s H  o  H  oPM     M     sn
n	5      U l        [#        U R                    V	V
s/ s H  o  H  oPM     M     sn
n	5      U l        UR%                  SS 5      b
  US   U l        UR%                  SS 5      b
  US   U l        U R                  U R                  -   S-  U l        UR%                  SS 5      b  US   U l        g g s  sn
n	f s  sn
n	f )Nr   zminzmaxrF   zmid)r   r   r   r   r   r   r   r   r2   npr
   ndarrayaminrM   amaxrN   minmaxgetrO   )selfr   r   r   r   r   r2   r   r3   rowrC   s              r   __init___AnnotatedHeatmap.__init__   sl    F3qt9%DFF3q6]DF&#2 #'66D $(&2*TVVRZZ00DIDI$&&>&3#QQ#Q&>?DI$&&>&3#QQ#Q&>?DI::fd#/vDI::fd#/vDIYY*a/	::fd#/vDI 0 ?>s   G&
G,
c                    / SQnS/nSnSnU R                   (       a!  U R                   S   nU R                   S   nXV4$ U R                  U;   a  U R                  (       a  UnUnXV4$ U R                  U;   a  UnUnXV4$ U R                  U;   a  U R                  (       a  UnUnXV4$ U R                  U;   a  UnUnXV4$ [        U R                  [        5      (       a  [        U R                  S   S   / SQ5      n[        U R                  S   S   / SQ5      nU R                  (       a  Xp[        U5      (       a  UnOUn[        U5      (       a  UnXV4$ Un XV4$ UnUnXV4$ )	a=  
Get font color for annotations.

The annotated heatmap can feature two text colors: min_text_color and
max_text_color. The min_text_color is applied to annotations for
heatmap values < (max_value - min_value)/2. The user can define these
two colors. Otherwise the colors are defined logically as black or
white depending on the heatmap's colorscale.

:rtype (string, string) min_text_color, max_text_color: text
    color for annotations for heatmap values <
    (max_value - min_value)/2 and text color for annotations for
    heatmap values >= (max_value - min_value)/2
)GreysGreensBluesYIGnBuYIOrRdRdBuPicnicJetHot	BlackbodyEarthElectricViridisCividisRedsz#FFFFFFz#000000r   r   )   rl   rl   )r2   r   r   r
   r   rD   rI   )	rW   colorscalescolorscales_reversewhiteblackmin_text_colormax_text_colormin_colmax_cols	            r   get_text_color _AnnotatedHeatmap.get_text_color   s    
"  &h!--a0N!--b1ND --C __+0A0A"N"N> --= __+"N"N8 --7 __ 338I8I"N"N2 --1 __ 33"N"N, --+ ..'(:1(=OG'(;A(>PG   #*$W--!&!&$W--!& --	 "' -- #N"N--r   c                    [         R                  U 5      u  p/ n[        U R                  5       H  u  pE[        U5       H  u  pgXpR                  :  a  UOUnUR                  [        R                  R                  [        U R                  U   U   5      U R                  U   U R                  U   SS[        US9SS95        M     M     U$ )z
Get annotations for each cell of the heatmap with graph_objs.Annotation

:rtype (list[dict]) annotations: list of annotations for each cell of
    the heatmap
x1y1)colorF)textr   r   xrefyreffont	showarrow)r.   ru   	enumerater   rO   appendr   r+   
Annotationstrr   r   r   r0   )	rW   rq   rr   r&   nrX   mval
font_colors	            r   r/   "_AnnotatedHeatmap.make_annotations  s     *;)I)I$)O&'FA#C./2YY^N
""%%00 !5!5a!8!;<&&)&&)!!!
3"' 1 
 ) ( r   )
r   r   r2   r   r   r   r   rN   rO   rM   N)	__name__
__module____qualname____firstlineno____doc__rY   ru   r/   __static_attributes__r,   r   r   r.   r.      s    $'LI.Vr   r.   )NNNPlasmaNFF)plotly.colorscolorsr?   plotlyr   r   plotly.figure_factoryr   plotly.graph_objsr   plotly.validators.heatmapr   
get_modulerP   r   r6   rD   rI   objectr.   r,   r   r   <module>r      sb     / ' ( 9   )"N 
c7LM Mr   