
    6DhP                     &   S r SSKrSSKrSSKrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS>S jrS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S S!S"S#S S!S$.r"S%S&S'S(S)S*S+S,S-S.S/.
r#S"S0S1S2S3S4S5S6S7S8S8S9.r$S:S;S<S=.r%g)?zG
Tools

A module for converting from mpl language to plotly language.

    Nc                 D   / nX!S   U S   :H  4-  nX!S   U S   :H  4-  nUS   S:X  a0  US   US   -
  nU S   U S   -
  nX#U-
  S:  4-  nX!S   U S   :H  4-  nO8US   S:X  a/  US	   US   -
  nU S	   U S   -
  nX%U-
  S:  4-  nX!S   U S   :H  4-  n[        U5      (       a  g
g)zCheck if two bars belong in the same collection (bar chart).

Positional arguments:
old_bar -- a previously sorted bar dictionary.
new_bar -- a new bar dictionary that needs to be sorted.

orientation	facecolorvx1x0gư>y0hy1TF)all)old_barnew_bartests	new_width	old_width
new_height
old_heights          N/var/www/html/env/lib/python3.13/site-packages/plotly/matplotlylib/mpltools.pycheck_bar_matchr      s    E	m$(>>@@E	k"gk&::<<E}$DMGDM1	DMGDM1	i'(244$-74=022		3	&T]WT]2
T]WT]2
z)H466$-74=022
5zz    c                    U R                  5       R                  5       nUR                  5       R                  5       nUS   S   US   S   :  a  gUS   S   US   S   :  a  gUS   S   US   S   :  a  gUS   S   US   S   :  a  gg)Nr   F      T)get_window_extentcorners)	inner_obj	outer_objinner_cornersouter_cornerss       r   check_cornersr    )   s    //199;M//199;MQ]1-a00	q	!	}Q/2	2	q	!	}Q/2	2	q	!	}Q/2	2r   c                 J   U [         ;   a	  [         U    $ U R                  S5      n[        U5      S:  a  g[        R                  " [        US   5      S5      (       a  gSR                  U Vs/ s H  o"S-   PM	     sn5      nUS:X  a  SnU$ US	:X  a  S
nU$ US:X  a  SnU$ s  snf )z@Convert mpl line symbol to plotly line symbol and return symbol.,   solidr           pxz7.4px,3.2pxdashedz12.8px,3.2px,2.0px,3.2pxdashdotz2.0px,3.3pxdotted)DASH_MAPsplitlenmathisclosefloatjoin)mpl_dash
dash_arrayxdashpxs       r   convert_dashr5   8   s    8!!^^C(
z?Q <<jm,c22 Z8Zt8Z89 ]"F
 	 11F  }$F 9s   -B c                 P    U S   n[        U S   5      nU[        ;   a	  [        U   $ g )Nr   r   )tuplePATH_MAP)pathvertscodes      r   convert_pathr<   V   s-    GEa>Dx~r   c                     [        U [        5      (       a$  [        5       nU  H  nU[        U5      /-  nM     U$ U [        ;   a	  [        U    $ g)z=Convert mpl marker symbol to plotly symbol and return symbol.circle)
isinstancelistconvert_symbol
SYMBOL_MAP)
mpl_symbolsymbolss      r   rA   rA   _   sM    *d##A~a())F 	z	!*%%r   c           	         ^ ^ T R                  S5      m [        T 5      m[        UU 4S j[        STTS-  5       5       5      $ )z
Change a hex color to an rgb tuple

:param (str|unicode) value: The hex string we want to convert.
:return: (int, int, int) The red, green, blue int-tuple.

Example:

    '#FFFFFF' --> (255, 255, 255)

#c              3   L   >#    U  H  n[        TXTS -  -    S5      v   M     g7f)r      N)int).0ilvvalues     r   	<genexpr>hex_to_rgb.<locals>.<genexpr>z   s*     P:OQU127{+R00:Os   !$r   r   )lstripr,   r7   range)rN   rM   s   `@r   
hex_to_rgbrS   l   s:     LLE	UBP%2rQw:OPPPr   c                 t    U c  g[        U 5      nUc  SR                  U5      $ X!4-   nSR                  U5      $ )z
Merge hex color with an alpha (opacity) to get an rgba tuple.

:param (str|unicode) color: A hex color string.
:param (float|int) opacity: A value [0, 1] for the 'a' in 'rgba'.
:return: (int, int, int, float) The rgba color and alpha tuple.

Nzrgb {}zrgba {})rS   format)coloropacityrgb_tuprgba_tups       r   merge_color_and_opacityrZ   }   sE     }Gw''#HH%%r   c                 *    U [         ;   a	  [         U    $ g)zConvert mpl vertical alignment word to equivalent HTML word.

Text alignment specifiers from mpl differ very slightly from those used
in HTML. See the VA_MAP for more details.

Positional arguments:
mpl_va -- vertical mpl text alignment spec.

N)VA_MAP)mpl_vas    r   
convert_var^      s     f~r   c                 v    U S   U S   U S   -   /nUS   US   -
  nUS   US   -
  U-  nUS   US   -
  U-  nXE/$ )a  Map x dimension of current plot to plotly's domain space.

The bbox used to locate an axes object in mpl differs from the
method used to locate axes in plotly. The mpl version locates each
axes in the figure so that axes in a single-plot figure might have
the bounds, [0.125, 0.125, 0.775, 0.775] (x0, y0, width, height),
in mpl's figure coordinates. However, the axes all share one space in
plotly such that the domain will always be [0, 0, 1, 1]
(x0, y0, x1, y1). To convert between the two, the mpl figure bounds
need to be mapped to a [0, 1] domain for x and y. The margins set
upon opening a new figure will appropriately match the mpl margins.

Optionally, setting margins=0 and simply copying the domains from
mpl to plotly would place axes appropriately. However,
this would throw off axis and title labeling.

Positional arguments:
mpl_plot_bounds -- the (x0, y0, width, height) params for current ax **
mpl_max_x_bounds -- overall (x0, x1) bounds for all axes **

** these are all specified in mpl figure coordinates

r   r#   r    )mpl_plot_boundsmpl_max_x_bounds	mpl_x_domplotting_widthr   r   s         r   convert_x_domainre      sp    0 !#_Q%7/!:L%LMI%a(+;A+>>N
A,)!,
,	>B
A,)!,
,	>B8Or   c                 v    U S   U S   U S   -   /nUS   US   -
  nUS   US   -
  U-  nUS   US   -
  U-  nXE/$ )a  Map y dimension of current plot to plotly's domain space.

The bbox used to locate an axes object in mpl differs from the
method used to locate axes in plotly. The mpl version locates each
axes in the figure so that axes in a single-plot figure might have
the bounds, [0.125, 0.125, 0.775, 0.775] (x0, y0, width, height),
in mpl's figure coordinates. However, the axes all share one space in
plotly such that the domain will always be [0, 0, 1, 1]
(x0, y0, x1, y1). To convert between the two, the mpl figure bounds
need to be mapped to a [0, 1] domain for x and y. The margins set
upon opening a new figure will appropriately match the mpl margins.

Optionally, setting margins=0 and simply copying the domains from
mpl to plotly would place axes appropriately. However,
this would throw off axis and title labeling.

Positional arguments:
mpl_plot_bounds -- the (x0, y0, width, height) params for current ax **
mpl_max_y_bounds -- overall (y0, y1) bounds for all axes **

** these are all specified in mpl figure coordinates

r   r   r   r`   )ra   mpl_max_y_bounds	mpl_y_domplotting_heightr	   r   s         r   convert_y_domainrj      sp    0 !#_Q%7/!:L%LMI&q),<Q,??O
A,)!,
,	?B
A,)!,
,	?B8Or   c                     XS   S   -
  nUS   US   S   US   S   -   -
  nXS   S   -
  nUS   US   S   US   S   -   -
  nX4-  XV-  4$ )a  Convert mpl display coordinates to plotly paper coordinates.

Plotly references object positions with an (x, y) coordinate pair in either
'data' or 'paper' coordinates which reference actual data in a plot or
the entire plotly axes space where the bottom-left of the bottom-left
plot has the location (x, y) = (0, 0) and the top-right of the top-right
plot has the location (x, y) = (1, 1). Display coordinates in mpl reference
objects with an (x, y) pair in pixel coordinates, where the bottom-left
corner is at the location (x, y) = (0, 0) and the top-right corner is at
the location (x, y) = (figwidth*dpi, figheight*dpi). Here, figwidth and
figheight are in inches and dpi are the dots per inch resolution.

marginlwidthrbheighttr`   )r3   ylayoutnum_xden_xnum_yden_ys          r   display_to_paperry      s     x %%E7Ovh/4vh7G7LLMEx %%E8x 0 5x8H8M MNE=%-''r   c                    / / / / 4u  pp4U R                  5        Hy  nUR                  5       R                  nUR                  US   5        UR                  US   US   -   5        UR                  US   5        UR                  US   US   -   5        M{     [	        U5      [	        U5      [        U5      [        U5      4u  pp$X4X444$ )aO  Return the entire axes space for figure.

An axes object in mpl is specified by its relation to the figure where
(0,0) corresponds to the bottom-left part of the figure and (1,1)
corresponds to the top-right. Margins exist in matplotlib because axes
objects normally don't go to the edges of the figure.

In plotly, the axes area (where all subplots go) is always specified with
the domain [0,1] for both x and y. This function finds the smallest box,
specified by two points, that all of the mpl axes objects fit into. This
box is then used to map mpl axes domains to plotly axes domains.

r   r#   r   r   )get_axesget_positionboundsappendminmax)figx_minx_maxy_miny_maxaxes_objr}   s          r   get_axes_boundsr      s     "$RRE%LLN&&(//VAYVAY*+VAYVAY*+ # "%USZUSZ!OE%>E>))r   c                 ^    U (       a  U(       a  gU (       a  U(       d  gU (       d  U(       a  gg)NticksFr`   )
main_spinemirror_spines     r   get_axis_mirrorr     s    l	LLr   c           	      2   [        U 5      [        U5      :X  at  [        U 5      S:  ad  U SS  nUS S n[        X45       VVs/ s H	  u  pVXV-
  PM     nnnUS   n[        U V	s/ s H  n	[        X-
  5      U:  PM     sn	5      n
U
(       a  U$ g g g s  snnf s  sn	f )Nr   r   )r,   zipr   abs)
bar_startsbar_endstolsides1sides2s2s1gapsgap0gapuniforms              r   get_bar_gapr     s    
:#h-'C
Oa,?AB#2&)&&9:&9FB&9:Aw=s4:,=>K  -@' ;=s    B!Bc           
      &   [        5       nU  HC  nU[        [        US   S-  5      [        US   S-  5      [        US   S-  5      US   S9/-  nME     [        5       nU H  nUSR                  " S0 UD6/-  nM     [	        U5      S:X  a  US   $ U$ )	Nr      r   r#   r   )ro   grp   azrgba({r},{g},{b},{a})r`   )r@   dictrJ   rU   r,   )
color_listclean_color_listcplotly_colorsrgbas        r   convert_rgba_arrayr   #  s    v3qtcz?c!A$*oQqTCZAaDQ
 	
  FM 188@4@AA !
=QQr   c                 r    [        5       nU  H  nU[        U5      /-  nM     [        U5      S:X  a  US   $ U$ Nr   r   )r@   r<   r,   )
path_arraysymbolsr9   s      r   convert_path_arrayr   2  s@    fGL&'' 
7|qqzr   c                 .    [        U 5      S:X  a  U S   $ U $ r   )r,   )width_arrays    r   convert_linewidth_arrayr   <  s    
;11~r   c                     U  Vs/ s H  n[         R                  " U5      PM     nn[        U5      S:X  a  US   $ U$ s  snf r   )r-   sqrtr,   )
size_arrayrE   sizes      r   convert_size_arrayr   C  s<    ",-*QDIIaL*D-
4yA~Aw	 .s    =c                     [        S [        U S   S   5      [        U S   5      [        U S   S   5      [	        U S   R                  5       5      [        U S   S   5      S9nU$ )Nstylesr   paths	linewidthmplobj	edgecolor)alphar   marker	edgewidth
markersizer   )r   r   r   r   r   	get_sizes)propsmarkerstyles     r   get_markerstyle_from_collectionr   K  sk    $U8_[%AB!%.1)%/+*FG%eHo&?&?&AB$U8_[%ABK r   c                 N    [        U S   S   U S   S   U S   S   U S   S   5      $ )z.Find minimum x value from four (x,y) vertices.r   r   r#   r   r   datas    r   get_rect_xminr   X  3    tAwqz471:tAwqz471:>>r   c                 N    [        U S   S   U S   S   U S   S   U S   S   5      $ )z.Find maximum x value from four (x,y) vertices.r   r   r#   r   r   r   s    r   get_rect_xmaxr   ]  r   r   c                 N    [        U S   S   U S   S   U S   S   U S   S   5      $ )z.Find minimum y value from four (x,y) vertices.r   r   r#   r   r   r   s    r   get_rect_yminr   b  r   r   c                 N    [        U S   S   U S   S   U S   S   U S   S   5      $ )z.Find maximum y value from four (x,y) vertices.r   r   r#   r   r   r   s    r   get_rect_ymaxr   g  r   r   c                    U R                   U   nU R                  5       nUR                  =(       d    Sn[        U[        5      (       a  US:X  a  SnOUS:X  a  SnUu  pVUS:X  a	  US:X  a  SnOS	nUR                  5       (       d  g	UR                  S
   (       d  g	U(       d  U(       a  g	U(       a  U(       a  gU(       d  U(       d  gg	)z8Return some spine parameters for the spine, `spine_key`.)outwardr%   center)axesg      ?zero)r   r   r   r   TFr   )spinesget_frame_on	_positionr?   strget_visible
_edgecolor)ax	spine_keyspineax_frame_onpositionposition_typeamountspine_frame_likes           r   get_spine_visibler   l  s    IIi E//#K2"2H(C  x$H"H$M	!fk b!-	)!1r   c                 ,    U  H  nUS   U;   d  M    g   g)zCA test to decide whether a path is a bar from a vertical bar chart.r   TFr`   )bar_containersr   	containers      r   is_barr     s"     $	?i' $ r   c                      U S   [        U S   5      [        U S   5      [        U S   5      [        U S   5      U S   S   U S   S   U S   S   U S   S   U S   S   U S   S	   S
.$ )a  Make an intermediate bar dictionary.

This creates a bar dictionary which aids in the comparison of new bars to
old bars from other bar chart (patch) collections. This is not the
dictionary that needs to get passed to plotly as a data dictionary. That
happens in PlotlyRenderer in that class's draw_bar method. In other
words, this dictionary describes a SINGLE bar, whereas, plotly will
require a set of bars to be passed in a data dictionary.

r   r   styler   r   r   r   	dasharrayzorder)barr   r	   r   r   r   r   r   r   r   r   )r   r   r   r   )r   s    r   make_barr     s     XE&M*E&M*E&M*E&M*w(7^K07^K07^K07^K0.* r   c           	         [        5       nUS:X  a  U R                  5       nO!US:X  a  U R                  5       nO
[        5       $ US   U   S   nUS:X  a   US   U   S   nUS   n[        S[	        U5      S-
  5       V	s/ s H  n	[        Xy   XyS-
     -
  S	5      PM     n
n	[        [        S[	        U
5      S-
  5       V	s/ s H  oU	   XS-
     :H  PM     sn	5      (       a  US   US   -
  nO+[        R                  " S
R                  U5      5        [        e XS'   XS'   SUS'   GOUS:X  Ga   US   U   S   S   US'   US   U   S   S   US   U   S   S   -
  US'   SUS'   UR                  5       R                  nUS:X  a  US:X  a<  [        R                  " US   S   5      [        R                  " US   S   5      /US'   O|US:X  a;  [        R                  " US   S   5      [        R                  " US   S   5      /US'   O:[        SSS9n[        R                  " SR                  U5      5        O
[        5       $ UR!                  5       R"                  R$                  nUS:X  aT  SU;   aN  SUS'    ['        US   U5      US'   UR+                  SS5        UR+                  SS5        ['        US   U5      US'   US:X  a  SUS'   U$ s  sn	f s  sn	f ! [        [        4 a    US   U   S   US'    Nf = f! [        [        4 a    [        US   U   S   S9n GNf = f! [(         a     Nf = f! UR+                  SS5        UR+                  SS5        ['        US   U5      US'   f = f)zPrepare axis obj belonging to axes obj.

positional arguments:
ax - the mpl axes instance
index - the index of the axis in `props`
ax_type - 'x' or 'y' (for now)
props - an mplexporter poperties dictionary

r3   rs   r   scalelinear
tickvaluesr   r      zF'linear' {0}-axis tick spacing not even, ignoring mpl tick formatting.tick0dtickNtickmodentickslog)r   
   xlimrR   ylim)rR   typez3Converted non-base10 {0}-axis log scale to 'linear'DateFormatterdater   LogFormatterMathtexteexponentformat)r   	get_xaxis	get_yaxisrR   r,   roundr   warningswarnrU   	TypeError
IndexErrorget_transformbaser-   log10get_major_formatter	__class____name__mpl_dates_to_datestringsKeyErrorpop)r   indexax_typer   	axis_dictaxisr   r   r   rL   dticksr   r	  	formatters                 r   
prep_ticksr    s    I#~||~	C||~v&M% )E	)vu-l;JqME q#j/A"566A jmjQ&77<6   aVq8QR8Q11IA.8QRSS"1
1544:F7O    "'g!&g$(Ij!	%	D!&vu!5l!CA!FIgfe$\215-&|4Q78 g %)Ij! !!#((2:#~JJuV}Q/0JJuV}Q/0&	'" CJJuV}Q/0JJuV}Q/0&	'"
 4h7IMMHOOPWX v((*44==I#~/Y6"	&	T!9)G:Li!XIg MM'4(MM*d+!9%-!SIg**&)	"#} S I& 	A"'-"6x"@Ih	A I& 	DE&M%$8$BCI	D6  		 MM'4(MM*d+!9%-!SIgsg   *K ? K!K  KAK 16K> ;L' 
K K;:K;>"L$#L$'
L41L7 3L44L7 78M/c                    [        US   S   S   [        US   5      US   S   S   S   [        US   U5      US   S   S   [        US   S   S	   S
9S9nUR                  [	        U SSU5      5        [        US   S   S   [        US   5      US   S   S   S   [        US   U5      US   S   S   [        US   S   S	   S
9S9nUR                  [	        U SSU5      5        XE4$ )Nr   r   r   r   gridgridOnr}   r   fontsize)r   )r   rR   showgriddomainsidetickfontr3   r   r   rs   )r   r@   re   updater  rj   )r   r   x_boundsy_boundsxaxisyaxiss         r   prep_xy_axisr%    s    6]1g&5=!vq!&)(3h:6]1j)5=+J78E 
LLB3./6]1g&5=!vq!&)(3h:6]1j)5=+J78E 
LLB3./<r   c                    U nUS:X  aY   [         R                  R                  U  Vs/ s H  o3S-  S-  S-  PM     sn5      n [         R                  R                  U 5      n O  [         R                  R                  U 5      n U  Vs/ s HC  nSR	                  UR                  5       R                  S5      S   R                  S5      5      PME     nnU$ s  snf !   Us $ = f!   Us $ = fs  snf )zConvert matplotlib dates to iso-formatted-like time strings.

Plotly's accepted format: "YYYY-MM-DD HH:MM:SS" (e.g., 2001-01-01 00:00:00)

Info on mpl dates: http://matplotlib.org/api/dates_api.html

TimeSeries_DateFormatter   <    +r   T)
matplotlibdates	epoch2numnum2dater0   	isoformatr+   )r.  mpl_formatter_datesr   time_stingss        r   r  r    s     F 22	$$..PU/VPUr	B0CPU/VWE$$--e4E	$$--e4E
 INHM!'',Q/55c:;   # 0W	M	Ms.   C C&C #C" A
C+C C"C(r$   dashr>   r(   )z10,0z6,6z2,2z4,4,2,4nonez7.4,3.2o*8r
   p1rE   r+  ^|)
)
MCr?  r?  r?  r?  r?  r?  r?  Z)r>  LrA  rA  rA  rA  rA  rA  rA  rA  r@  )	r>  rA  rA  rA  rA  rA  rA  rA  r@  )r>  rA  rA  rA  rA  rA  r@  )r>  rA  rA  rA  rA  r@  )r>  rA  r>  rA  r>  rA  )r>  rA  rA  rA  r@  )r>  rA  r>  rA  )r>  rA  rA  r@  )r>  rA  ztriangle-downztriangle-upztriangle-leftztriangle-rightsquarecrossr3   stardiamond)r7  r   r<  <>rE   r+  r3   r8  Ddmiddlebottomtop)r   baselinerL  )g|=)&__doc__r-   r  matplotlib.datesr-  r   r    r5   r<   rA   rS   rZ   r^   re   rj   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r%  r  r*   r8   rB   r\   r`   r   r   <module>rP     s$     6<
Q"&( >>(**2
?
?
?
?
:4Vr,H  9<=@36),$'$'" 
										
 (5	Ar   