
    er                     
   d dl Z d dlZd dlZd dlZddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ d	d
lmZmZ d	dlmZ ddlmZ ddlmZmZmZmZmZ  G d dee          Z G d de          Z G d dee          ZdS )    N   )Tiles)util)Element)
DynamicMap)Stream)dim   )GenericElementPlotGenericOverlayPlot)dim_range_key   )
PlotlyPlot)STYLE_ALIASESget_colorscalelegend_trace_typesmerge_figuremerge_layoutc                   X    e Zd Z ej        dd          Z ej        eefdd          Z	 ej
        dd          Z ej        dd	          Z ej        dd
          Z ej        dd          Z ej        g dd          Z ej        dd          Z ej        dd          Z ej        dd          Z ej        dd          Z ej        dd          Z ej        dd          Z ej
        dg dd          Z ej        dd          Z ej
        dg dd          Z ej        dd          Z ej        dd          Z ej        dd          ZdZ dZ!dZ"g Z#d- fd	Z$e%d              Z&d.d!Z'd.d"Z(d/d#Z)d0d%Z*d/d&Z+d' Z,d( Z-d) Z.d/d*Z/d+ Z0d1d,Z1 xZ2S )2ElementPlotcubea  
        The aspect ratio mode of the plot. By default, a plot may
        select its own appropriate aspect ratio but sometimes it may
        be necessary to force a square aspect ratio (e.g. to display
        the plot as an element of a grid). The modes 'auto' and
        'equal' correspond to the axis modes of the same name in
        matplotlib, a numeric value may also be passed.defaultdocNzC
        If set bgcolor overrides the background color of the axis.)class_r   r   Fz
        Inverts the axes of the plot. Note that this parameter may not
        always be respected by all plots but should be respected by
        adjoined plots when appropriate.z+
        Whether to invert the plot x-axis.z+
        Whether to invert the plot y-axis.z+
        Whether to invert the plot z-axis.)xyzz/
        Whether to label the 'x' and 'y' axes.zB
         Whether to apply log scaling to the x-axis of the Chart.zB
         Whether to apply log scaling to the y-axis of the Chart.)2   r   r   r   zg
         Margins in pixel values specified as a tuple of the form
         (left, bottom, right, top).zF
         Whether the plot should stretch to fill the available space.z-
        Whether to show legend for the plot.bottom)topr    bareztop-barezbottom-bareNz
        Whether and where to display the xaxis, bare options allow suppressing
        all axis labels including ticks and xlabel. Valid options are 'top',
        'bottom', 'bare', 'top-bare' and 'bottom-bare'.)r   objectsr   z
        Ticks along x-axis specified as an integer, explicit list of
        tick locations, list of tuples containing the locations.left)r$   rightr"   z	left-barez
right-bareNz
        Whether and where to display the yaxis, bare options allow suppressing
        all axis labels including ticks and ylabel. Valid options are 'left',
        'right', 'bare' 'left-bare' and 'right-bare'.z
        Ticks along y-axis specified as an integer, explicit list of
        tick locations, list of tuples containing the locations.zl
        An explicit override of the z-axis label, if set takes precedence
        over the dimension label.z
        Ticks along z-axis specified as an integer, explicit list of
        tick locations, list of tuples containing the locations.c                 V    t                      j        |fi | t          t          j                              | _        t          | j                  dk    o)t          | j                  t          | j                  k    | _	        | 
                                \  | _        | _        d S )Nr   )super__init__struuiduuid4	trace_uidlenhmapkeysstatic_construct_callbacks	callbackssource_streams)selfelementplotparams	__class__s       Alib/python3.11/site-packages/holoviews/plotting/plotly/element.pyr(   zElementPlot.__init__s   s    ++F+++TZ\\**$)nn)Nc$)nnDI.N.2.G.G.I.I++++    c                     i S N )clskwargss     r9   trace_kwargszElementPlot.trace_kwargsy   s    	r:   c                     |                      | j        d         ||          }d| _        | j        }g | _        t	          j        |           |S )N
        Initializes a new plot object with the last available frame.
        is_geoT)generate_plotr/   drawn_triggerr   trigger)r4   rangesrE   figrI   s        r9   initialize_plotzElementPlot.initialize_plot}   sN    
   2v FF
-w
r:   c                      j          _        |                     |          }n| _         |r' j        s t	          dt          |           d          | j        d         S                      |d          j        }  j	        j
        di  fd|                                D                                    j        ||          }t          j        ||          }                     |d           _         j         j                 }|rF fd|D             }|r6t	          d                    t          |          j        |	                                         ||||
          }                     ||||
          }	g g g g d}
t-          |          D ]\  }}                     ||	||          }|                    dg           }|
d                             |           |dk    r|r j        |d         d<   dD ]1}|
|                             |                    |g                      2d|v r|d         |
d<   |
 j        d<                        ||||
          }dD ]G}|                    |g            ||                             |
                    |g                      Hd|
v r*t;          |                    di           |
d                    | j        d<    j        |d<   t?          |
d         |t?           j                            }| j        d<                         |           d _!        |S )NzElements of type z@ cannot be overlaid with Tiles elements using the plotly backendrK   r6   c                 .    i | ]\  }}|j         v ||S r=   )param).0kvr4   s      r9   
<dictcomp>z-ElementPlot.generate_plot.<locals>.<dictcomp>   s1     4 4 4da#$
?? #2??r:   stylec                 &    g | ]}|j         v |S r=   )unsupported_geo_style_opts)rP   	style_optr4   s     r9   
<listcomp>z-ElementPlot.generate_plot.<locals>.<listcomp>   s1          ' ??? ???r:   zxThe following {typ} style options are not supported by the Plotly backend when overlaid on Tiles:
    {unsupported_opts})typunsupported_optsrD   )tracesimagesannotationsshapes)indexrE   r[   r   uid)r\   r^   r]   mapbox
componentslayoutautosize)
responsive)datarc   configTr=   )"current_frame
prev_frame
_get_frame_supports_geo
ValueErrortypehandleslookup_optionsoptionsrO   updateitemscompute_rangesr.   r   
match_specrT   cyclic_indexformat__name__get_datagraph_options	enumerate
init_graphgetextendr,   init_layout
setdefaultr   re   dict_execute_hooksrG   )r4   keyrJ   r5   rE   	plot_optsrT   rZ   rf   optsrb   iddatum_componentsr[   rQ   rc   rK   s   `                 r9   rF   zElementPlot.generate_plot   s   -?ooc**GG!(D 	$, 	?DMM ? ? ?  
 ?<&& ''88@	
 	5 	5 4 4 4 4ioo.?.? 4 4 4 	5 	5 	5 $$TYV<<&11 (('::

4,-  	       +0         --3V MM2EU .4 . .   }}WfeF}CC!!'65!HH 	
 

 dOO 	B 	BDAq#q$aOO &))(B77Fx ''///Avv&v $(>q	%  9 B B1$$%5%9%9!R%@%@AAAA +++'7'A
8$%/\" !!#wv!FF4 	4 	4Aa$$$1IZ^^Ar223333z!!**8R88*X:NOOO!'X "_z
8,VDTXTcDdDdDdeee!UG$$$

r:   c                 z  
 | j         r7d                    d | j                                         D                       }n|j        }t	          dd|i|                     |          }|                     |                              dd           t          v r'|                    | j	        |j
        dz   |z              | j        |                     |||          }t          j        d| j        z   dz             

fd	|                                D             }d
 |                                D             || j        <   dD ]B}	|	|                    | j        i           v r#|| j                                     |	          ||	<   Cn1|                    d |                                D                        |S )Nz, c                 >    g | ]\  }}|                     |          S r=   )pprint_value_stringrP   r   rR   s      r9   rX   z-ElementPlot.graph_options.<locals>.<listcomp>   s6      ;  ;  ;TQ 5 5a 8 8  ;  ;  ;r:   namerD   rm   _)
showlegendlegendgroup^c                 D    i | ]\  }}                     d |          |S ) )sub)rP   rQ   rR   key_prefix_res      r9   rS   z-ElementPlot.graph_options.<locals>.<dictcomp>  s/    MMMdam''A..MMMr:   c                 @    i | ]\  }}t          j        ||          |S r=   r   r|   rP   rQ   rR   s      r9   rS   z-ElementPlot.graph_options.<locals>.<dictcomp>  sA     %A %A %A)-A &3%6q!%<%<a %A %A %Ar:   )selectedpointsvisiblec                 L    i | ]!\  }}|d k    t          j        ||          |"S )cmapr   r   s      r9   rS   z-ElementPlot.graph_options.<locals>.<dictcomp>  s>     C C C!Qa6kk '*1a00!6Akkr:   r=   )overlay_dimsjoinrr   labelr   r@   r|   r   rq   show_legendgroup
_style_key_apply_transformsrecompilepop)r4   r5   rJ   rT   rE   r?   legendr   stylesrQ   r   s             @r9   ry   zElementPlot.graph_options   s    	#YY  ;  ; $ 1 7 7 9 9 ;  ;  ; < <FF ]F = ==,,F,;;= = F++//==ASSSKK+s9J69Q  S S S ?&++GVUCCF
 JsT_'<s'BCCMMMMMfllnnMMMF%A %A17%A %A %AD! 3 ; ;"5555"4?377::DG;
 KK C C%*[[]]C C C D D D r:   r   c                    t          |          }|                                D ]E\  }}||v r7t          ||         t                     r||                             |           @|||<   F| j        r| j        r{d || j                                                 D             }t          || j                           || j        <   |                                D ]\  }	}
|
|         || j                 |	<   d|giS )a  
        Initialize the plotly components that will represent the element

        Parameters
        ----------
        datum: dict
            An element of the data list returned by the get_data method
        options: dict
            Graph options that were returned by the graph_options method
        index: int
            Index of datum in the original list returned by the get_data method

        Returns
        -------
        dict
            Dictionary of the plotly components that represent the element.
            Keys may include:
             - 'traces': List of trace dicts
             - 'annotations': List of annotations dicts
             - 'images': List of image dicts
             - 'shapes': List of shape dicts
        c                 N    i | ]"\  }}t          |t          j                  ||#S r=   )
isinstancenpndarrayr   s      r9   rS   z*ElementPlot.init_graph.<locals>.<dictcomp>5  s>     8 8 841a'2:668!Q 8 8 8r:   r[   )r   rr   r   rq   r   
_per_trace)r4   datumrp   r_   r?   tracerQ   rR   
vectorizedsvals              r9   r{   zElementPlot.init_graph  s   . WKKMM 	 	DAqEzzjq488za""""a? 	7t 	78 874?+C+I+I+K+K 8 8 8J%)%*@%A%AE$/"$**,, 7 73,/Jdo&q))5'""r:   c                     g S r<   r=   )r4   r5   rJ   rT   rE   s        r9   rx   zElementPlot.get_data=  s    	r:   c                      | j         | j        z  S )z7
        Computes the aspect ratio of the plot
        )widthheight)r4   xspanyspans      r9   
get_aspectzElementPlot.get_aspectA  s     z$+%%r:   c                     |                                 dd         }dgt          dt          |          z
  d          z  }||z   S )zReturns the dimensions corresponding to each axis.

        Should return a list of dimensions or list of lists of
        dimensions, which will be formatted to label the axis
        and to link axes.
        Nr   r   )
dimensionsmaxr-   )r4   r5   dimspads       r9   _get_axis_dimszElementPlot._get_axis_dimsH  sH     !!##BQB'fS3t99a(((czr:   c           	        	 t          |          }t          |                                          D ]\  }	t          	t                    rl|dk    r	dv r&	|v rt	          	          	nMt          	fd| j        D                       r-t	          t          	fd| j        D                                 	t          	t                    s	                    |          sS	j	        | j        vrE|
                    |           | j                            d                    |	                     t          	j                  dk    r!	j	        | j        v r| j        	j	                 }n	                    ||d          }t#          j        |          s1t          t#          j        |                    d	k    rd
|vr|d         }t#          j        |          sR|| j        v rIt+          |          j        }t/          d                    |	j	        || j        j                            t          |t4          j                  o|j        j        dv }d
|v r_t          |t4          j                  rE|rC|                     	|||          }|
                    dd            |                    |           |||<   |S )Nmarkerxsdoc              3   $   K   | ]
}|k    V  d S r<   r=   r   s     r9   	<genexpr>z0ElementPlot._apply_transforms.<locals>.<genexpr>\  s'      99!A999999r:   c              3   (   K   | ]}|k    |V  d S r<   r=   r   s     r9   r   z0ElementPlot._apply_transforms.<locals>.<genexpr>]  s'       F FqA F Fr:   z^Specified {} dim transform {!r} could not be applied, as not all dimensions could be resolved.r   T)rJ   flatr   colorzMapping a dimension to the "{style}" style option is not supported by the {element} element using the {backend} backend. To map the "{dim}" dimension to the {style} use a groupby operation to overlay your data along the dimension.)rT   r	   r5   backenduifMmr   ) r   rr   r   r)   r	   anyr   nextapplies	dimensionr   rO   warningrv   r-   opsapplyr   isscalarunique_array_nonvectorized_stylesrm   rw   rl   rendererr   r   r   dtypekindget_color_optsrq   )
r4   r5   rJ   rT   	new_stylerQ   r   numericcoptsrR   s
            @r9   r   zElementPlot._apply_transformsT  s   KK	KK%%'' ,	 ,	DAq!S!! H==Q&[['\\AAA9999t'899999 HD F F F FD,= F F FFFGGAa%% ii(( Q[@Q-Q-Qa   
"" $==CVAq\\K K K15zzQ1;$2C#C#C'4gggf4g@@M#&& 3t/@/E/E+F+F!+K+K1$$!f=%% 
I222"7mm4G$ &Q
 RXQW/0ak7151F RX RH RHI I I !bj11Ocin6OG1C!<!<++AwFFfd+++  '''IaLLr:   c                    |                     d t          g          }|r|d         n|}t          |                     |d          | j        d          }| j        s| j        |d<   | j        |d<   |                     ||          }t          |          d	k    r|\  }}	}
}n	|\  }}	}}
}}| 
                    |          }t          |          d
k    r|\  }}}n|\  }}d }|                     |          \  }}}| j        r$|rt          d          ||}}||}}|	|||
f\  }}	}
}d| j        vrd}d| j        vrd}d| j        vrd}i }|r>|s;	 t          t!          j        |
|g                    rd\  }
}n# t$          $ r Y nw xY w| j        r|
|gn||
g}t          ||          }| j        r"d|d<   t!          j        |d                   |d<   |                     || j                   | j        dk    r| j        rd|d<   t5          |t6          t8          f          r d                    d |D                       }n|j         d|j         d|j          }||d<   d| j        v rd|d<   d|d<   d|d<   d | j        v rd |d!<   nd"|d!<   i }|r?|s<	 t          t!          j        |	|g                    rd\  }	}n# t$          $ r Y nw xY w| j!        r||	gn|	|g}t          ||          }| j"        r"d|d<   t!          j        |d                   |d<   |                     || j#                   | j        dk    r| j$        rd|d<   t5          |t6          t8          f          r d                    d# |D                       }n|j         d|j         d|j          }|f|d<   d| j$        v rd|d<   d|d<   d|d<   d$| j$        v rd$|d!<   nd%|d!<   |rQi }tK          d& ||	|
|fD                       r,||
z   d'z  }|	|z   d'z  }tM          j'        |g|g          \  }}t          |d         |d         (          |d)<   | j(        \  }} }!}"| j        |z
  |!z
  }#| j        |"z
  | z
  }$d*}%d
t           j)        z  d+z  }&|
|z
  }'||	z
  }(t!          j*        d,-          5  t!          j+        |&|'z            t!          j+        |%|#z            z
  })t!          j+        |&|(z            t!          j+        |%|$z            z
  }*d d d            n# 1 swxY w Y   tY          |)|*          |d.<   ||d/<   t5          | j        tZ                    r| j        dk    rt          ||0          }+|rL| j.        r||gn||g},t          |,|          }-| j/        rd|-d<   |                     |-| j0                   |-|+d1<   | j1        d2k    rd2|+d3<   nd4|+d3<   | j1        |+d5<   |+|d6<   n/| j(        \  }}	}
}t          ||
|	|d	7          |d8<   |s
||d9<   ||d:<   |S );Nc                     | S r<   r=   )r   s    r9   <lambda>z)ElementPlot.init_layout.<locals>.<lambda>  s     r:   r    )	separatorT)titleplot_bgcolor
uirevisionr   r      r
   zTThe invert_axes parameter is not supported on Tiles elements with the plotly backendr   r   r   r   )r   r   )ranger   logrm   r   3dF
automargin-c                 @    g | ]}|j          d |j         d |j         S r   r   r   unitrP   r   s     r9   rX   z+ElementPlot.init_layout.<locals>.<listcomp>  D     (7 (7 (7,- ,-6(F(FAG(F(Faf(F(F (7 (7 (7r:   r   _dimr"   ticksshowticklabelsr   r!   sider    c                 @    g | ]}|j          d |j         d |j         S r   r   r   s     r9   rX   z+ElementPlot.init_layout.<locals>.<listcomp>  r   r:   r%   r$   c              3   >   K   | ]}t          j        |          V  d S r<   )r   isfinite)rP   rR   s     r9   r   z*ElementPlot.init_layout.<locals>.<genexpr>   s*      88a2;q>>888888r:   g       @)latloncenteri   iRa ignore)dividezoomra   )xaxisyaxiszaxisr   
aspectmodemanualaspectratioscene)lrbtr   marginr   r   )2traverser   r   _format_titlebgcolorre   r   r   get_extentsr-   r   _get_axis_labelsinvert_axesrl   labelledr   r   isnan	TypeErrorinvert_xaxislogxlog10
_get_ticksxticks
projectionr   r   listtupler   r   r   r   invert_yaxislogyyticksr   allr   easting_northing_to_lon_latmarginspierrstatelog2minr)   invert_zaxislogzzticksaspect).r4   r   r5   rJ   rE   elrc   extentr  r  r  r  z0z1r   xdimydimzdimxlabelylabelzlabelr   xrangedim_strr   yrangera   x_centery_centerlonslatsmargin_leftmargin_bottommargin_right
margin_topviewport_widthviewport_heightmapbox_tile_size	max_deltax_deltay_delta
max_x_zoom
max_y_zoomr  zranger   s.                                                 r9   r~   zElementPlot.init_layout  s   kkG955%RUUg$$SC$88$
 
 

  	+"jF7O#{F8!!'622v;;!JAq!QQ!'Aq"aB""2&&t99q==#D$JD$D!%!6!6t!<!< 	$  .   $VFFt$DAq!JAq!Qdm##Fdm##Fdm##F #	- #	-rxA''((  DAq     $0<aVVq!fFvV444Ey : %f!#%.!9!9gOOE4;///$&&4:&&+l# dT5M22 F!hh (7 (715(7 (7 (7 8 8GG "&EETZEE$)EEG 'fTZ''%'E'N.3E*+%'E'NDJ&&$)E&MM$,E&M "	+ "	+rxA''((  DAq     $0<aVVq!fFvV444Ey : %f!#%.!9!9gOOE4;///$&&4:&&+l# dT5M22 F!hh (7 (715(7 (7 (7 8 8GG "&EETZEE$)EEG 'fTZ''%'E'N.3E*+%'E'Ndj(($+E&MM$*E&M 	&F88Aq!Q<88888 =ES=ES=">zH:VV
d#'DGa#A#A#Ax  HL|D]L*!%k!9L!H"&+
":]"J#& I/	a%a%[111 M M"$')g*=">"> "(8>(I J J#KJ"$')g*=">"> "(8?(J K K#LJM M M M M M M M M M M M M M M
 "%Z!<!<v%F8dos++ 	(40G0GuE222E '%)%6D"bRH68889 *$)E&Mt{333!&g{f$$&,l##&.l#'+{m$#F7OOJAq!Q#a1QA>>>F8 ("'w"'ws7   (E8 8
FF(J; ;
KKAS>>TTc                     i }t          |t          t          f          rXt          d |D                       r#t	          | \  }}d |D             }||d<   ||d<   n||d<   |                    |           d S d S )Nc              3   @   K   | ]}t          |t                    V  d S r<   )r   r  )rP   r  s     r9   r   z)ElementPlot._get_ticks.<locals>.<genexpr>4  s,      88A:a''888888r:   c                 Z    g | ](}t          |t                    r|nt          |          )S r=   )r   r)   )rP   r  s     r9   rX   z*ElementPlot._get_ticks.<locals>.<listcomp>6  sA     / / /"#  *!S11=!!s1vv / / /r:   tickvalsticktext)r   r  r  r  ziprq   )r4   axisticker
axis_propsr   labelss         r9   r  zElementPlot._get_ticks1  s    
fudm,, 		$8888888 0 #Vv/ /'-/ / /).
:&)/
:&&)/
:&KK
#####		$ 		$r:   c                 8    |                      ||||           dS )zV
        Updates an existing plot with data corresponding
        to the key.
        rD   N)rF   )r4   r   rJ   r5   rE   s        r9   update_framezElementPlot.update_frame>  s'    
 	3?????r:   r<   NF)Fr   NNF)3rw   
__module____qualname__rO   	Parameterr&  ClassSelectorr)   r  r
  ObjectSelectorr  Booleanr  r  r#  Listr  r  r  r$  NumericTupler  re   r   r   r  r   r  Stringr0  r%  r   r   rk   r   r(   classmethodr@   rL   rF   ry   r{   rx   r   r   r   r~   r  rP  __classcell__)r8   s   @r9   r   r      s       U_V 2; < < <F "e!#ut JF G G GG '%&u ;, - - -K
 !5= 5. / / /L !5= 5. / / /L !5= 5. / / /L uz/// 82 3 3 3H 5= -E F F FD EM% .E F F FD EM% .E F F FD !e )9 @( ) ) )G u 3I J J JJ  %- 40 1 1 1K !E *? *? *?E;< < <E U_T 0D E E EF !E /C /C /CI9: : :E U_T 0D E E EF U\$ -% & & &F U_T 0D E E EF J J M J J J J J J   [   b b b bJ# # # #J$# $# $# $#N   & & &	 	 	/ / /di i i iV$ $ $@ @ @ @ @ @ @ @r:   r   c                      e Zd Z ej        ej        ej        fdd          Z ej        de	e
efd          Z ej        dd          Z ej        d	e	efd
          Z ej        i d          Z ej        dd          Zd Zd	S )ColorbarPlotr
   z
        User-specified colorbar axis range limits for the plot, as a
        tuple (low,high). If specified, takes precedence over data
        and dimension ranges.)r   lengthr   Fz
        Percentile value to compute colorscale robust to outliers. If
        True, uses 2nd and 98th percentile; otherwise uses the specified
        numerical percentile value.)r   r   r   z'
        Whether to display a colorbar.r   Nz
        Number of discrete colors to use when colormapping or a set of color
        intervals defining the range of values to map each color to.z
        Allows setting including borderwidth, showexponent, nticks,
        outlinecolor, thickness, bgcolor, outlinewidth, bordercolor,
        ticklen, xpad, ypad, tickangle...z<
        Whether to make the colormap symmetric around zero.c                    i }t          |          }| j        rt          di | j        |d<   d|d         vr~t	          |t
                    rWt          |          }|j        rnG|                    d          r |	                    d          r|dd         }n|dd         }n|j
        }||d         d<   d	|d
<   nd|d
<   |r d}t          j        | j                                                  r| j        \  }	}
n||v r5| j        rd||         v r||         d         \  }}nZ||         d         \  }	}
nHt	          |t
                    rt           j        t           j        }
}	d	}n|                    |          \  }	}
| j        r?t!          j        |	|
g          }|                                 |                                }
}	nd	}d\  }	}
|                    dd          }t/          || j        |	|
          }t	          |t2                    r\t5          |          dk    rI|d         }t7          t!          j        t5          |          dz                      }|dd |         }||d<   |	|	|d<   |
|
|d<   ||d<   ||d<   |S )Ncolorbarr   zdim('z')   r   rC   T	showscaleFrobustcombined)NNr   viridis   r   cmincmaxcauto
colorscaler=   )r   rc  r   colorbar_optsr   r	   r)   r   
startswithendswithpprint_labelr   r   climr  clim_percentiler   nanr   	symmetricabsr   r   r   color_levelsr  r-   intceil)r4   eldimr5   rJ   rT   r   dim_namer   autork  rl  lowhighcabsr   rn  last_clr_pairsteps                     r9   r   zColorbarPlot.get_color_optsa  s    ''= 	&#99d&899Dd:...eS)) 	/JJEy ,))'22 ,u~~d7K7K , %ad %ad!.E*/Z ) $D %D 	$D}TY''++-- 5!Y
ddV##' >Hx8H,H,H &x 0 :IC!'!1*!=JD$$E3'' 5VRVd$]]844
d~ 5vtTl++"hhjj[$((**dD#JD$yy++#D$*;T4HH
 j$'' 	+C
OOc,A,A&rNMrws:45566D#AGtG,J*JrNDLDLW'\r:   )rw   rT  rU  rO   r[  r   ru  rs  rW  ry  floatboolrt  rY  rc  r  rx  Dictro  rv  r   r=   r:   r9   r`  r`  F  s       5rvrv&6q G! " " "D
 *e)%eT@R Y' ( ( (O
 u}U 1* + + +H '5&tS$K NH I I IL EJr 0- . . .M
 e 2? @ @ @IA A A A Ar:   r`  c                   .    e Zd Zg dZddZddZddZdS )	OverlayPlot)r   r   r   r   r  r
  r  
show_frame	show_gridr  r  r  toolbarr  	xrotation	yrotationre   r  r  sizing_moder   title_formatpaddingr.  r/  r0  xlimylimzlimNFc                     |                      t          t          | j        j                                                            ||          S )rB   rD   )rF   r   iterr.   rf   r/   )r4   rJ   rE   s      r9   rL   zOverlayPlot.initialize_plot  s@    
 !!$tDIN,?,?,A,A'B'B"C"CVTZ![[[r:   c                    ||                      |          }|g n%t          |j                                                  }|                     |d          j        |                     |d| j        d          } j        d	i fd|                                D               | j	        j        d	i  | 
                    | j        ||          }d }|D ]\  }}	t          |	t                    rd} n| j                                        D ]\  }
}|A|j        r:|                     |
|||          \  }}}||                    |          \  }}	nd }	nd }	 |j	        j        d	i  |                    |||	|          }||}zt'          ||           |                     ||||          }t+          |d         |           d| _        || j        d<   |S )
Nr6   F)defaultsc                 0    i | ]\  }}|v	||d          S rR  r=   )rP   rQ   rR   r   s      r9   rS   z-OverlayPlot.generate_plot.<locals>.<dictcomp>  s-    XXX1QiEWEWAqtEWEWEWr:   TrD   rc   rK   r=   )rj   r  rf   rr   ro   rp   _traverse_options_propagate_optionsrq   rO   rs   r.   r   r   subplotsrG   _match_subplotr   rF   r   r~   r   rn   )r4   r   rJ   r5   rE   rr   	inheritedfigurer   r'  okeysubplotidxspecexactrK   rc   r   s                    @r9   rF   zOverlayPlot.generate_plot  s=   ?ooc**Go40B0B0D0D+E+E ''88@	**7F+/+B49 + ; ;	 		YYXXXX	0A0AXXXYYY
&&I&&&$$TYV<<
  	 	EAr"e$$  "]0022 	* 	*MD'"w}"#'#6#6tWeW#U#U T5?!IIcNNEArrBB !GM --9---''VR'GGC~VS))))!!#wv!FFVH%v...
$Ur:   c                    t          | j        t                    o| j        }| j        | _        |s||                     |          }n||| _        || _        |g n%t          |j	        
                                          }|D ]\  }}t          |t                    rd}| j        
                                D ]U\  }	}
t          | j        t                    r|"|                     |	|
||          \  }}}||                    |           Vt          | j        t                    r|r|                     |||           |                     ||||           d S )NTrD   )r   r.   r   overlaidrh   ri   rj   current_keyr  rf   rr   r   r  r  r   _create_dynamic_subplotsrF   )r4   r   rJ   r5   rE   reusedrr   r   r'  rQ   r  r  s               r9   rP  zOverlayPlot.update_frame  sp   DIz22Dt}- 	#'/ooc**GG !(D"Do40B0B0D0D+E+E 	 	EAr"e$$  ---// 	 	JAwty*55 ':M++AwwGGICA		#di,, 	> 	>))#uf===3?????r:   rQ  rS  )rw   rT  rU  r  rL   rF   rP  r=   r:   r9   r  r    sp        I I I\ \ \ \0 0 0 0d@ @ @ @ @ @r:   r  )r   r*   numpyr   rO   r   r   corer   core.elementr   core.spacesr   streamsr   util.transformr	   r6   r   r   r   r   r   r   r   r   r   r   r`  r  r=   r:   r9   <module>r     s   				                   # # # # # # % % % % % %       ! ! ! ! ! ! 9 9 9 9 9 9 9 9                               j@ j@ j@ j@ j@*0 j@ j@ j@Z\ \ \ \ \; \ \ \~[@ [@ [@ [@ [@$k [@ [@ [@ [@ [@r:   