
    e                    0   d dl Z d dlmZ d dlmZ 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mZmZmZmZmZmZmZmZmZ d dlmZmZ d dlmZmZmZ d dlmZm Z  d d	l!m"Z"m#Z#m$Z$ d d
l%m&Z&m'Z'm(Z( d dl)m*Z* d dl+m,Z,m-Z-m.Z.m/Z/m0Z0 d dl1m2Z2 d dl3m4Z4 ddl5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z; ddl<m=Z=m>Z>m?Z? ddl@mAZAmBZBmCZCmDZDmEZEmFZF ddlGmHZHmIZImJZJ ddlKmLZL ddlMmNZNmOZO ddl;mPZPmQZQmRZRmSZS ddlMmTZT ddlUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z] ddl^m_Z_ ddl;m`Z`maZambZbmcZcmdZdmeZemfZfmgZgmhZhmiZimjZjmkZkmlZlmmZmmnZnmoZompZpmqZqmrZrmsZsmtZtmuZu 	 e2jv        Zwn# ex$ r e`ZwY nw xY w G d deTeN          Zy G d d ey          Zz G d! d"ey          Z{ G d# d$ey          Z| G d% d&          Z} G d' d(eOe|          Z~dS ))    N)chain)FunctionType)ModelChangedEvent)
BinnedTickerColorBarColorMapperCustomJSEqHistColorMapperGlyphRendererLegendRendererTitletools)CategoricalAxisDatetimeAxis)CustomJSTickFormatterMercatorTickFormatterTickFormatter)TabPanelTabs)CategoricalColorMapperLinearColorMapperLogColorMapper)DataRange1dFactorRangeRange1d)LogScale)BasicTickerFixedTicker	LogTickerMercatorTickerTicker)Tool)Version   )CompositeOverlayDataset	Dimension
DynamicMapElementutil)KeywordsSkipRenderingabbreviated_exception)
AnnotationContoursGraphPathTilesVectorField)BufferPlotSizeRangeXYdim   )GenericElementPlotGenericOverlayPlot)color_intervalsdim_axis_labeldim_range_keyprocess_cmap   )	BokehPlot)base_propertieslegend_dimensionsline_propertiesmpl_to_bokehproperty_prefixes
rgba_tupletext_propertiesvalidate)	TablePlot)
TOOL_TYPESbokeh32bokeh_versioncds_column_replacecompute_layout_propertiesdate_to_integerdecode_bytesdtype_fix_hookget_axis_class	get_scaleget_tab_titleglyph_orderhold_policymatch_ax_typematch_dim_specsmatch_yaxis_type_to_rangeprop_is_noneproperty_to_dictrecursive_model_updateremove_legendtheme_attr_jsonwrap_formatterc                   N    e Zd Z ej        dd          Z ej        dg dd          Z ej        dg dd	          Z ej	        d
d          Z
 ej        dd          Z ej        i d          Z ej	        dd          Z ej        dddd          Z ej        dddd          Z ej        dddd          Z ej        dddd          Z ej        ddd          Z ej        ddd          Z ej        ddd          Z ej        ddd          Z ej        dd          Z ej        dd          Z ej        deefd          Z ej	        dddd           Z  ej        dg d!"          Z! ej        d#d$idd%&          Z" ej        i d'          Z# ej        d(d)gd*          Z$ ej        d
dd+d,d-d.          Z% ej        dd/          Z& ej        dd0          Z' ej        g d1d2          Z( ej        g d3          Z) ej        d4g d5d6          Z* ej        de+e,e-fd7          Z. ej        de+e,e-fd7          Z/dZ0dZ1g Z2e3Z4e3Z5dZ6dh fd8	Z7d9 Z8dhd:Z9d; Z:dhd<Z;d= Z<e=d>             Z>dddd?d@Z?dA Z@dhdBZAdC ZBdD ZCdE ZDdF ZE	 	 didGZFdhdHZGdI ZHdJ ZIdK ZJdL ZKdM ZLdN ZMdO ZNdjdPZOdQ ZPdR ZQdS ZRdT ZSdU ZTdV ZUdW ZVdX ZWdhdYZXdhdZZYd[ ZZd\ Z[d] Z\d^ Z]d_ Z^dkd`Z_da Z`db Zadc ZbdlddZc fdeZddf Zee=dg             Zf xZgS )mElementPlotNaG  
        Allows specifying which tools are active by default. Note
        that only one tool per gesture type can be active, e.g.
        both 'pan' and 'box_zoom' are drag tools, so if both are
        listed only the last one will be active. As a default 'pan'
        and 'wheel_zoom' will be used if the tools are enabled.defaultdocstart)rg   centerendzD
        Alignment (vertical or horizontal) of the plot in a layout.re   objectsrf   )xyNz
        Whether to auto-range along either the x- or y-axis, i.e.
        when panning or zooming along the orthogonal axis it will
        ensure all the data along the selected axis remains visible.
   z$
        Minimum border around plot.a(  
        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 specifying the ratio between plot
        width and height may also be passed. To control the aspect
        ratio between the axis scales use the data_aspect option
        instead.aL  
        A dictionary of custom options to apply to the plot or
        subcomponents of the plot. The keys in the dictionary mirror
        attribute access on the underlying models stored in the plot's
        handles, e.g. {'colorbar.margin': 10} will index the colorbar
        in the Plot.handles and then set the margin to 10.z\
        Defines the aspect of the axis scaling, i.e. the ratio of
        y-unit to x-unit.,  Tr   Nz
        The width of the component (in pixels). This can be either
        fixed or preferred width, depending on width sizing policy.)re   
allow_Noneboundsrf   z
        The height of the component (in pixels).  This can be either
        fixed or preferred height, depending on height sizing policy.zK
        Minimal width of the component (in pixels) if width is adjustable.re   rr   rf   zM
        Minimal height of the component (in pixels) if height is adjustable.z
        Allows to create additional space around the component. May
        be specified as a two-tuple of the form (vertical, horizontal)
        or a four-tuple (top, right, bottom, left).Fa  
       Enables multiple axes (one per value dimension) in
       overlays and useful for creating twin-axis plots.

       When enabled, axis options are no longer propagated between the
       elements and the overlay container, allowing customization on a
       per-axis basis.z
       Enables sub-coordinate systems for this plot. Accepts also a numerical
       two-tuple that must be a range between 0 and 1, the plot will be
       rendered on this vertical range of the axis.re   class_rf   rA   )FTzN
       Scale factor for subcoordinate ranges to control the level of overlap.)re   rr   inclusive_boundsrf   )FTwidthheight)re   rk   title12pta  
       Specifies various fontsizes of the displayed text.

       Finer control is available by supplying a dictionary where any
       unmentioned keys reverts to the default sizes, e.g:

          {'ticks': '20pt', 'title': '15pt', 'ylabel': '5px', 'xlabel': '5px'})re   rq   rf   z
        Allows customizing the grid style, e.g. grid_line_color defines
        the line color for both grids while xgrid_line_color exclusively
        customizes the x-axis grid lines.rl   rm   z0
        Whether to plot the 'x' and 'y' labels.i    )factorinterval	thresholdtimeoutaG  
        Bokeh plots offer "Level of Detail" (LOD) capability to
        accommodate large (but not huge) amounts of data. The available
        options are:

          * factor    : Decimation factor to use when applying
                        decimation.
          * interval  : Interval (in ms) downsampling will be enabled
                        after an interactive event.
          * threshold : Number of samples before downsampling is enabled.
          * timeout   : Timeout (in ms) for checking whether interactive
                        tool events are still occurring.zA
        Whether or not to show a complete frame around the plot.z^
        Whether to invert the share axes across plots
        for linked panning and zooming.)savepan
wheel_zoombox_zoomresetz*A list of plugin tools to use on the plot.z3
        A list of plugin tools to use on the plot.right)abovebelowleftr   disableNz^
        The toolbar location, must be one of 'above', 'below',
        'left', 'right', None.z.
        Formatter for ticks along the x-axis.c                 X   d | _         d | _         t                      j        |fi | |i n| j        d         | _        t          | j                  dk    o)t          | j                  t          | j                  k    | _        | 	                                \  | _
        | _        d| _        d | j        D             | _        t          | j        j                            d t$                              | _        | j        r| j        d| _        ddd| _        g | _        d| _        d S )NplotrA   Fc                 <    g | ]}t          |t                    |S  )
isinstancer5   .0ss     @lib/python3.11/site-packages/holoviews/plotting/bokeh/element.py
<listcomp>z(ElementPlot.__init__.<locals>.<listcomp>  s'    KKKZ65J5JK!KKK    c                     | S Nr   rl   s    r   <lambda>z&ElementPlot.__init__.<locals>.<lambda>  s     r   mercator)x-main-rangey-main-range)_subcoord_standalone_current_rangessuper__init__handleslenhmapkeysstatic_construct_callbacks	callbackssource_streamsstatic_sourcestreams	streamingboollasttraverser3   
geographic
projection_shared_js_on_data_callbacks_updated)selfelementr   params	__class__s       r   r   zElementPlot.__init__  s   %)""++F+++!\rrt|F/C$)nn)Nc$)nnDI.N.2.G.G.I.I++"KKT\KKKty~66{{EJJKK? 	)t6(DO ).uEE%'" r   c                    | j         rt          | j        j        j                  }n&t          | j                                                  }||                                z  }t          t          j	        |                    i fS r   )
batchedlistr   r   kdimsoverlay_dimsr   
dimensionsr+   unique_iterator)r   r   dimss      r   _hover_optszElementPlot._hover_opts  sr    < 	2	,--DD)..0011D""$$$D(..//33r   c                 P   |g }|                      |          \  }}d |D             }|sd}|| j        z   }g g }}d}|D ]}}|j        D ]s}	|	ro|	t          v rf|                    |	           |	dk    rt          j        d|dgd|}
|
}nt          |	                     }
|                    |
           |
| j        |	<   t~g }|| j        z   | j        z   D ]}
|
|v r|
dv rt          j        d|dg|
d|}
nUt          rN|
d	v rJ|

                    d
          rd}n|

                    d          rd}nd}t          j        d|dg          }
|                    |
           g }|D ]\}
t          |
t
          j                  r+|
                    d          } t          |
          di |}
|                    |
           ]d |D             }d|v r.t          j        d|dgd|}|||                    d          <   nt#          |          r|d         }|r
|| j        d<   d |D             }|r|d         | j        d<   d |D             }|r|d         | j        d<   |rH|rF|d                             d|d         d           |d                             d|d         d           |S )I
        Processes the list of tools to be supplied to the plot.
        Nc                     g | ]<}t          |t                    r#|j        d t          j        |j                  z  fn|=S @{%s}r   r(   pprint_labelr+   dimension_sanitizernamer   ttps     r   r   z+ElementPlot._init_tools.<locals>.<listcomp>(  s\     P P P?Bz#y11;S%w1I#(1S1S'STT7:P P Pr   Fhover
hv_created)tooltipstags)vlinehline)r   r   mode)r   xwheel_zoomywheel_zoomrl   rw   rm   rx   bothnone)zoom_togetherr   r   include_defaultsc                 F    g | ]}t          |t          j                  |S r   r   r   	HoverToolr   ts     r   r   z+ElementPlot._init_tools.<locals>.<listcomp>X  s)    QQQQ*Q2P2PQqQQQr   r   c                 F    g | ]}t          |t          j                  |S r   )r   r   BoxSelectToolr   s     r   r   z+ElementPlot._init_tools.<locals>.<listcomp>a  s*    SSS1
1e>Q0R0RSQSSSr   
box_selectc                 F    g | ]}t          |t          j                  |S r   )r   r   LassoSelectToolr   s     r   r   z+ElementPlot._init_tools.<locals>.<listcomp>d  s*    WWWQ*Q@U2V2VWqWWWr   lasso_selectr   r   )r   r   models	TOOLS_MAPappendr   r   r   default_toolsrM   
startswithWheelZoomToolr   r#   properties_with_valuestypeindexanyjs_link)r   r   r   r   
hover_optscb_tools
tool_namesr   cbhandletool	tool_list	zoom_dimscopied_tools
propertieshover_tools	box_toolslasso_toolss                     r   _init_toolszElementPlot._init_tools!  s    I#//88*P PFNP P P(Ddn,	!2* 	0 	0B) 0 0 
0f	11%%f---(($  *%-\N *  *( *  * !%(022OOD)))+/DL(0 	t11DJ> 	# 	#Dz!!))) %\N IS   	T%QQQ??3'' ' 'II__S)) ' (II &I*"(Yl^   T"""" 	& 	&D$
++ 0!88%8PP
!tDzz//J//%%%%QQ,QQQl""OYX\NYYjYYE8=L++G4455 	#NE 	*$)DL!SSSSS	 	6)21DL&WW,WWW 	:+6q>DL(  	A 	AaL  Q@@@N""69Q<@@@r   c                 8   | j         d         }d|j        v r-|                     |          \  }}d |D             }||_        d S |j                            dd          }d |j                            dg           D             }|r|d         j        |_        d S d S )	Nr   r   c                     g | ]<}t          |t                    r#|j        d t          j        |j                  z  fn|=S r   r   r   s     r   r   z-ElementPlot._update_hover.<locals>.<listcomp>s  s\     T T TCF:c955?)7T5Mch5W5W+WXX;>T T Tr   r   bokehc                 F    g | ]}t          |t          j                  |S r   r   r   s     r   r   z-ElementPlot._update_hover.<locals>.<listcomp>x  s8     < < <q&q%/::< < < <r   r   r   )r   r   r   r   optsgetkwargs)r   r   r   r   r   	plot_opts	new_hovers          r   _update_hoverzElementPlot._update_hovero  s    |G$49$$#'#3#3G#<#< HjT TJRT T TH$DMMM((99I< <I$4$8$8"$E$E < < <I 6 )! 56 6r   c           
         d| j         vs| j        rdS |p|                                D ]7}t          j        |j                  }||vr|                    |          ||<   8| j                                        D ]d\  }}t          j        |j                  }||vrB|gt          t          t          |                                                              z  ||<   edS )zv
        Initializes hover data based on Element dimension values.
        If empty initializes with no data.
        r   N)r   r   r   r+   r   r   dimension_valuesr   itemsr   nextitervalues)r   datar   r   dr9   kvs           r   _get_hover_datazElementPlot._get_hover_data}  s    
 $,&&$*<&F4 2 2 4 4 	8 	8A*1622C$#44Q77S	%++-- 	A 	ADAq*1622C$C#d4+>+>&?&?"@"@@S		A 	Ar   c                 D   d}|t           u }|D ]}|||dk    rdnd}	t          ||	 dd          }
t          ||	 dd          }t          |d|	 di           }|
rQ|
j        rJt          |
j        d         |          r/t	          |d         |          r|rt          |t                     r|
}| nl|                                D ]U}|j        rLt          |j        d         |          r1t          |||j                  r|rt          |t                     r|} nV|S )	z
        Given a list of other plots return the shared axis from another
        plot by matching the dimensions specs stored as tags on the
        dimensions. Returns None if there is no such axis.
        Nr   rl   rm   _rangeaxisextra__ranges)	r   getattrr   rZ   rY   r   r  r[   r   )r   plotsspecs
range_type	axis_typepos	dim_rangecategoricalr   ax
plot_rangeaxesextra_rangesextra_ranges                 r   _shared_axis_rangezElementPlot._shared_axis_range  s    	 K/ 	 	D|u}qcB "}}}d;;J4Bd33D"4)=")=)=)=rBBL ')'
 2E::' d1gy11' !	' *4I{)K)K	' '	$+2244  $)89I!9Le)T)T-dI{?OPP % .8	;-O-O
 !,IEr   c                     | j         | j         S t          | t                    r| j        p#t          | t                     o| j        o| j        | _         | j         S )z
        Indicates when the context is a subcoordinate plot, either from within
        the overlay rendering or one of its subplots. Used to skip code paths
        when rendering an element outside of an overlay.
        )r   r   OverlayPlotsubcoordinate_yoverlaid)r   s    r   _subcoord_overlaidzElementPlot._subcoord_overlaid  sc     %1--k**Ct/C [D+...Y4=YTEY 	" ))r   )r9   range_tags_extrasextra_range_namec                *
   |g }|                     d d g          }	|	r|	d         n|}	t          |	t                    r|	j        }	| j        rt          | t
                    s|	n|}
|dk    r`r^g}t          j        fd                                D                       \  }}t                    }j
        j        j        ff}n	 |                     |
          \  }}}}n+# t          $ r |                     |
          \  }}}}Y nw xY w| j        r||||f\  }}}}|dk    r`| j        rYt          | j        t$                    r9| j        dz  }d|z
  t)          |                      d                     d	z
  |z   }}nd
\  }}n|dk    r||fn||f\  }}t+          |                     |	                    }| j        r|d d	         d d d         \  |d<   |d<   ||         }|r2t          |t*                    s|g}t/          d |D                       }nd }rt                    }n.|                     |r|nd          \  }}}| j        r||}}|r|n|}|r|d d	         d d d         }t3          |                      d                     }| j        rd}n;|t3          fd|D                       rd}nt3          d ||fD                       }| j        | j        f}| j        r|d d d         }||         }| j        | j        f|         rdnd}|rt=          |          dk    s	|t>          u rd}d}n{|	                     |d                   r`|	!                    |d                   }|tD          j#        u r'tI          tK          |          t          j&                  s|t          j&        v rd}| '                    |	d          j(        }|p	|dk    rdnd}|rD| j)        r=|*                    dd          s's%| +                    |||||          } | r
d| j,        |<   | j,        *                    |          rsn|rd}t?                      } nnd ||fv st3          d ||fD                       r |            } nBtI          |t>                    r |rj
        nd           } n |||rj
        nd           } | j-        s6|4| j-        .                    |           | j-        .                    |           |r|| _
        ||| fS )Nc                     | S r   r   r   s    r   r   z)ElementPlot._axis_props.<locals>.<lambda>       r   c                 f    t          | t                    ot          | t          t          f           S r   )r   r*   r/   r3   els    r   r   z)ElementPlot._axis_props.<locals>.<lambda>  s+    z"g7N7N7zWabdgqsxfyWzWzSz r   r   rA   c                 V    g | ]%}|                     j        d di          d          &S )combinedNN)r  r   )r   elranger9   s     r   r   z+ElementPlot._axis_props.<locals>.<listcomp>  sC     % % % CHz<&@AA*M% % %r   	dimension       @c                     | j         S r   )r'  )ps    r   r   z)ElementPlot._axis_props.<locals>.<lambda>  s	    1CT r   r:   )r   rA   c              3   >   K   | ]}|j         |j        |j        fV  d S r   )r   labelunitr   r  s     r   	<genexpr>z*ElementPlot._axis_props.<locals>.<genexpr>  s/      FFAqvqw7FFFFFFr   r4  c                     | j         S r   )_categorical)r   s    r   r   z)ElementPlot._axis_props.<locals>.<lambda>  s	    T5F r   Fc              3   H   K   | ]}|j         v od |j                  v V  dS )factorsNr   )r   r9   rangess     r   r@  z*ElementPlot._axis_props.<locals>.<genexpr>  s>      %k%k_bch&&8&ZY&QTQYJZ=Z%k%k%k%k%k%kr   Tc              3   N   K   | ] }t          |t          t          f          V  !d S r   )r   strbytesr   r  s     r   r@  z*ElementPlot._axis_props.<locals>.<genexpr>  s0      LLajS%L99LLLLLLr   logautodatetimenormr   r   axiswisec              3      K   | ]D}t          |t          t          ft          j        z             rd nt          j        |           V  EdS )TN)r   rH  rI  r+   cftime_typesisfiniter   r1  s     r   r@  z*ElementPlot._axis_props.<locals>.<genexpr>(  se       %
 %
+- rC<0A#ABB 'DD]2&&&%
 %
 %
 %
 %
 %
r   rE  )rg   ri   r   )/r   r   r1   nodesr   r&  r+   	max_ranger  rH  r   r=  r>  get_extents	TypeErrorinvert_axesr)  r'  r   subcoordinate_scalesumr   _get_axis_dimstuple_get_axis_labelsr   _x_range_type_y_range_typelogxlogyr   r   get_dimensionget_dimension_typenpobject_
issubclassr   datetime_typeslookup_optionsoptionsshared_axesr  r$  r   r   r   )!r   r  subplotsr   rF  r  r9   r*  r+  r1  range_elr   v0v1
axis_labelr  lbrr   offset	axis_dimsxlabelylabelzlabelr  range_typesr  r  dim_type	norm_optsshared_namer  s!       ` `                          r   _axis_propszElementPlot._axis_props  sN    $ "kk,z,z+{||%RUUgb%   	BXj{.K.KX22QX
 !8885D^ % % % %%}}% % %  FB SJh	3846EE@!--h#-NN
1a @ @ @ "--h??
1a@  (1aZ
1aaxxD3xd2D99 "!5:F vXs4==9T9T+U+U'V'VWX'XY_'_BB!FB#&!88!Q!QBT004455I A-6rr]44R4-@*	!ilS>D !$-- " 6DFFFFFFF 7 XX

)-)>)>t?]ttQ])^)^&# 4%+VFF'*6VV
 &BQBx"~$--(F(FGGHH 	MKK#%k%k%k%kfj%k%k%k"k"kKKLLB8LLLLLK)4+=><;ttt+<[ %
"i3C8DEEf	 	+4yy1}}
k 9 9"	"!!$q'** +00a99++
488TEX0Y0Y+ 333 *I''F33;	&ZSAXX>>> 	1T% 	1immJ.N.N 	1WZ 	1//uj)UXYYI 1,0[)<K(( 	U 	U 	UI#IIb"X %
 %
24b%
 %
 %
 "
 "
 #
II
K00 	U"
C(ATBBBII"
c:S#((tTTTI~ 	5%"3N!!%(((N!!"3444 	.-IN*i//s   C- -%DDc                 Z   | j         rd\  }}nd\  }}i i i }	}}d}
t          || j                                                  D ]\  }}|                    |          d d         }|j         r|d d d          |d         }|j                            dd	          j        }t          |t                    r	|j
        |v r}| j        r#|                    d
          |j        }|
dz  }
n|j
        }||	|<   |                    dt          |          r|n|          |                    dd           |                    dd          |                    dd          |                    dd          |                    dt          j        t          j        f          |                    dt!          |                    |                    d                              d          |                    d                              d          d| j        r|
dz
  nd d	||<   |                                D ]\  }}d|d         i}|d
         |d
         |d
<   |d         dk    rXd|d<   |d         d         |d         d         }}|t          j        |          s||d<   |t          j        |          s||d<   nd|d<   |                     ||||d|	|         ||          }| j         r|d         n|d         }|rdn|d         }||d         |d         |d         |d         f||<   ||fS )N)r   r   r   r   r   r:   r;  rA   r   r   )backendr'  yaxis	autoranger`  Fra  invert_yaxisylimrv  fontsizeyticks)axis_label_text_font_sizemajor_label_text_font_size)	positionr  r`  ra  r  r  r=  r  r'  rm   T
y-lowerlim
y-upperlim)r  r9   r*  r+  rK  r=  r  )rX  ziprk  r  r[  r  r  r  r   r(   r   r)  r=  r   rd  nanr>   	_fontsizer	  isnanr|  )r   r  rk  r   rF  axpos0axpos1ax_specsyaxesr   subcoordinate_axesr1  spax_dimsydr  ax_nameydiminfor*  lowerlimupperlimax_propslog_enabledax_types                            r   _create_extra_axeszElementPlot._create_extra_axes:  s    	--NFFF,NFF&("b%'4=#7#7#9#9:: 	 	FB''++BQB/G~ "B7;;vw;77>Db),, 50@0@& "88-..6("a'""'"$Jw HHWE

.NffOO!XXk488//// $ ? ?"&"&)9::(N2,>,>??13h1G1G1K1KJ1W1W24,,x2H2H2L2LZ2X2X  @D?V#`$6$:$:\` E'NN   ++-- 	 	JD$!/n1E F%&27;<M7N!"34K C''15!+.%)&\!_d6l1o(!)bhx.@.@)6>%l3!)bhx.@.@)6>%l316!+.''x&aZ=M"3!% (  H
 +/*:L$v,,VK*;eeGgT*5EtJGWHTNN hr   c                 	   | j         r&t          | j                                                   ng }i i d}|                     ||||d          | j        i fz   |d         d<   | j        rXt          s| j                            d           | 	                    ||||          \  }}|d         
                    |           nd| j        i}	| j        dk    rFd|	d	<   | j        \  }
}|
t          j        |
          s|
|	d<   |t          j        |          s||	d<   nd|	d	<   |                     ||||d|	          | j        i fz   |d         d<   | j        r6| 	                    ||||          \  }}|d         
                    |           i i i d}}|                                D ]"\  }}|                                D ]\  }\  }}}}}t'          ||          }| d|v rX|                    d| di           x|d| d<   }|||<   | j        s(|                    d| di           x|d| d<   }|||<   {||| d<   ||| d<   ||| d<   |r|| j        v r||| d<   |dk    rdddnddd}|d||         d<   ||         
                    |           |                                D ]\  }}|r||v r||| d<   $| j        sd|d<   | j        r| j        |                     |d !          }nd"}| j        d#k    r%|                     |          }||d$<   | j        |d%<   n
g |d$<   d
|d%<   | j        j        rd&|d'<    |j
        d-i |                     ||           t@          j!        j"        }tG          j$                    5  tG          j%        d(tL                      |d-d)|i|} d
d
d
           n# 1 swxY w Y    | j        d         j
        d-i |d           | j        d         j
        d-i |d          | j        r| S | j'        rdnd}!|                    d|! di                                           D ]\  }}"||!         |         \  }}}}}tQ          ||"d*          \  }#}$||$|! d+<   |$
                    |           |d|$d<   |!dk    rdnd}|!| j        v r||$d,<    |#d-i |$}%| )                    |%|           | S ).z
        Initializes Bokeh figure to draw Element into and sets basic
        figure and axis attributes including axes types, labels,
        titles and plot height and width.
        rl   rm   r   )r  rl   zHIndependent axis zooming for multi_y=True only supported for Bokeh >=3.2rm   r  Tr  Nr  r  FrA   )r  r*  r  r  r  _scales_scale
_axis_type_axis_labelr   r   r~  r   r   )bottomtopvisible_axis_locationoutline_line_alpha 	separator r   r   toolbar_locationwebgloutput_backendignorery   r8   _range_namero  r   )*rk  r   r  r|  xaxismulti_yrM   paramwarningr  updater  r  r  rd  r  r  r)  r	  rU   r  r'  labelled
show_frame
show_titleadjoined_format_titletoolbarr   rendererr  _plot_propertiesr   plottingfigurewarningscatch_warningssimplefilterUserWarningrX  rT   
add_layout)&r   keyr   r  rF  rk  
axis_specsr  extra_axis_specsr*  r  r  _r   
axis_propsr  	axis_specaxis_dimr  ro  
axis_rangeaxis_positionr  scaler"  extra_scaleslocslocr  ry   r   r  figmulti_ax	range_objax_cls	ax_kwargsr  s&                                         r   
_init_plotzElementPlot._init_plot{  s    48=H4,,..///bB''
#//x&VW/XX\`\fhj[kk
3< 	! o
""#mnnn&*&=&=eXwX^&_&_#E#sO""#34444!/1B C~$$15!+.%)Y"(!)bhx.@.@)6>%l3!)bhx.@.@)6>%l316!+.#'#3#3x&aK\ $4 $ $R $!JsOC  " 	5"&"9"9%7TZ"["[AsO""#3444!#2B%7%7J
)//11 	F 	FOD)\e\k\k\m\m F FXWIz:}h!*i88???j00HRWm`dWmWmWmoqHrHrrJ55556-7L*/ 7LVNN[qdh[q[q[qsuLvLvv
#9D#9#9#9:\16X.2<J$/27J$/6?J$2223! Fddm&;&;;E
d#7#7#78AEFW===]dmtRuRuD$,6;
4(3t$++H555$(JJLL F FS( FSM-A-ABEJ$'>'>'>?F%F,  	1/0J+,? 	t}4&&sc&::EEE<9$$$$W--E"'Jw-1\J)**"$Jw-1J)*= 	3+2J'(
@@D11#w??@@@&$&& 	4 	4 !(K888&33u3
33C		4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4
 		!..jo...	!..jo... " 	J*333#->>2L82L2L2Lb#Q#Q#W#W#Y#Y 	. 	.Hi@J8@TU]@^=Iz1mX .y) K K KFI2:I.../X&&&$',	)$+3s??4=((*4	,'$$)$$BNN2}----
s   %N??OOc                 ,   d| j         v}| j        j        dz  }|                     |dddgd          }|r| j        nd}t          | j        | j        | j        | j	        |
                    d          |
                    d          | j        | j        | j        ||          \  }}|s|d	         | j        j        |d	<   | j        | j        | j        | j        | j        | j        d
}	|	                    |           | j        s|	                    |           | j        r
| j        |	d<   | j        dD ]}
| j        |	d|
z   <   d| j        v r"t5          | j        d         j        fi | j        n| j        }|                                D ]\  }}||	d|z   <   |	S )z:
        Returns a dictionary of plot properties.
        r   g      Y@rw   rx   FdefaultsN)loggeraspect_ratio)alignmargin	max_width
max_height	min_width
min_heightbackground_fill_color)r   r   r  r  min_border_lodlod_)r   r  size_traverse_optionsr  rP   rw   rx   frame_widthframe_heightr  aspectdata_aspect
responsivestater  r  r  r  r  r  r  r  drawnbgcolorborderdictre   r  r	  )r   r  r   initsize_multiplierri  r  aspect_propsdimension_props
plot_propsr:  r  lod_propr  s                 r   r  zElementPlot._plot_properties  s    T\)-,T1((&7H:MX](^^#-(AJT%5t7HKK  '++h"7"7dFVO_V)= )= )=%o
  	GN+3/3z/F^, "Z![!^!_!^!_
 

 	,'''z 	/o...< 	?26,J./;"7 : :.2k
=?++=Bdj=P=Pd4:e$,99999VZV^99;; 	, 	,KHa*+Jvh''r   c                    || j         dk    rdS | j        $t          | j        | j        z             }ddh|z  }n| j        }|g k    rd|j         _        |D ]&}t          |t                    rct          j	        |t          d                    fd|j         j        D             }|s| j                            d|d           s|d         }t          |t          j                  r||j         _        t          |t          j                  r||j         _        t          |t          j                  r||j         _        t          |t          j                  r|j         j                            |           (dS )	z"Activates the list of active toolsNr   r   r   c                 4    g | ]}t          |          |S r   )r   )r   r   	tool_types     r   r   z1ElementPlot._set_active_tools.<locals>.<listcomp>!  s7     9 9 9!)!Y779A 9 9 9r   zTool of type z: could not be found and could not be activated by default.r   )r  active_toolssetr   r   active_dragr   rH  rL   r  r   r  r  DragScrollactive_scrollTap
active_tapInspectToolactive_inspectr   )r   r   enabled_toolsr  r   matchingr  s         @r   _set_active_toolszElementPlot._set_active_tools  s   <4<944F$ 2TZ ?@@M"L1MALL,L2'+DL$  	9 	9D$$$ 
#&N4d<<	9 9 9 9t|'9 9 9 9 J&&A A A A   {$
++ 0+/($-- 2-1*$	** /*.'$ 122 9+224888'	9 	9r   c                     | j         r| j        |                     |d          }nd}t          |          }|                     d                              d          }|dk    r||d<   |S )	Nr  r  r  )textry   r  rz   text_font_size)r  r  r  r  r  r  )r   r  r   r   ry   r  
title_fonts          r   _title_propertieszElementPlot._title_properties3  s~    ? 	t}4&&sc&::EEE ^^G,,00<<
%/D!"r   c                    |j         d         | j        d<   |j        | j        d<   |j        | j        d<   |j        | j        d<   |j        d         | j        d<   |j        | j        d<   |j        | j        d<   |j        | j        d	<   d S )
Nr   r  x_rangeextra_x_rangesextra_x_scalesr  y_rangeextra_y_rangesextra_y_scales)	r  r   r  r  r  r  r  r  r  )r   r   s     r   _populate_axis_handlesz"ElementPlot._populate_axis_handles@  s     $
1W"&,Y)-)<%&)-)<%& $
1W"&,Y)-)<%&)-)<%&&&r   c                 :
   |ddd}t          t          | j        j        d                    }|dk    r	| j        dv s|dk    r!| j        d	v rd
}||d<   ||d<   d|d<   d|d<   n|                     | d                              d          }|r||d<   |                     | dd                              d          }	|	r|	|d<   |dk    r| j        n| j	        }
|
rt          j        |
          |d<   |dk    r| j        n| j        }t          |t          j                  rt!          |          }t          |t"                    r||d<   nt          |t$                    rt'          |          |d<   nt          |t(          t           f          rt+          d |D                       r%t-          | \  }}d |D             }d |D             }n|d}}|r&t/          j        |d                   rd |D             }t3          |          |d<   | t          t-          ||                    |d<   n| j        r|dk    rg g }}d}t-          | j        | j                                                  D ]t\  }}|j        st          |j        t>                    r|ndtA          |j                  z  }|dz  }|!                    |           |!                    |j"                   ut3          |          |d<   | t          t-          ||                    |d<   |dk    r| j#        n| j$        }|rtK          ||          }|||d<   nOtL          H|rFt          |tN                    r1d}|j(        r|j(        }n |j)        |j*        v r|j*        |j)                 }|dk    r|j        d         }n|dk    r|j        d         }| j+        rt          | j,        tZ                    r| j,        dk    r|dk    rd nd!}t]          |"          |d<   t_          |"          |d<   | j0        1                    td          j3        #          }|rd$|d         _4        | j0        1                    td          j5        #          }|rd|d         _6        nt          |tn                    r}t!          |          D ]8}|8                    d%          r!|9                    d%d&          }||         ||<   9|                     d'| dd                              d          }|||d<   |S )(zb
        Returns a dictionary of axis properties depending
        on the specified axis.
        Nr   rA   r  Axisrl   )zbottom-bareztop-barebarerm   )z	left-barez
right-barer  0ptr  r  major_tick_line_colorminor_tick_line_colorr=  r  ticksFcommonmajor_label_orientationticker)desired_num_ticksc              3   @   K   | ]}t          |t                    V  d S r   )r   r\  r   s     r   r@  z/ElementPlot._axis_properties.<locals>.<genexpr>n  s,      <<z!U++<<<<<<r   c                     g | ]<}t          |t                    r#|                                rt          |          n|=S r   )r   float
is_integerintr   s     r   r   z0ElementPlot._axis_properties.<locals>.<listcomp>r  sO     - - -!" (2!U';';UUSVVVTU - - -r   c                 Z    g | ](}t          |t                    r|nt          |          )S r   )r   rH  )r   rp  s     r   r   z0ElementPlot._axis_properties.<locals>.<listcomp>t  sA     / / /"# $.a#5#5Aaa3q66 / / /r   c                 8    g | ]}t          j        |d           S )ms)r+   	dt_to_int)r   ticks     r   r   z0ElementPlot._axis_properties.<locals>.<listcomp>y  s$    JJJDT^D$77JJJr   )r  major_label_overrides      ?	formatterr   lonlatr6  r   Tmajor_labelgroupminor_):r  r`   r  themer  r  r  r  	xrotation	yrotationrd  radiansxticksr  r   ndarrayr   r"   r)  r   r\  allr  r+   
isdatetimer   r)  current_framerk  r  r'  r   rZ  r   r=  
xformatter
yformatterra   r   r(   value_formatr   type_formattersr   r   rH  r!   r   r  selectr   BoxZoomToolmatch_aspectr   zoom_on_axisr   r   replace)r   r  r  r   r7  
ax_mappingr  zero_pt	labelsizeticksizerotationr#  r  labelsidxr1  r  ycenterr1  axis_objr   r   new_keymsizes                           r   _axis_propertieszElementPlot._axis_propertiesJ  s     q))J/$-*=vFFGG
S[[TZ+NNNS[[TZ+NNNG6=J237>J3426J./26J.//$~~~66:::FFI D:C
67~~nnnU~CCGG
SSH D;C
78)-t~~$.H M8:
88L8L
45$(CKKT[[T[F&"*-- &f&&))  S'-
8$$FC(( S'2V'L'L'L
8$$FUDM22 S<<V<<<<< 	1$'LME6- -&+- - -E/ /'-/ / /FF %+D6E KT_U1X66 KJJEJJJE'2'?'?'?
8$%:>s5&?Q?Q:R:RJ67( STS[[ "Bv!$"4dm6J6J6L6LMM , ,FB- ! %/0BD%I%IlccsUXY[YkUlUlOlG1HCLL)))MM"(++++'2'?'?'?
8$%:>s5&?Q?Q:R:RJ67'+s{{DOO	 		F&y$77I$*3
;'".:.*YXaBbBb.I% F%2		9#<<<%5inE	3;;z!}HHS[[z!}HO 	A
4?C @ @ 	A:--!%%I#1I#F#F#FJx &;i&P&P&PJ{#z((e.?(@@H 0+/(**0C*DDJ 3-2
1*/22 	AJ'' : :>>-00 :!kk-AAG*4S/Jw'
 NN#7D#7#7#7 #  !c*oo  ;@
78r   c                      |j         di |                     ||           | j        s|                     |||           |                     |||           |                     |           dS )z8
        Updates plot parameters on every frame
        Nr   )r  r  r  _update_labels_update_title_update_gridr   r  r   r   s       r   _update_plotzElementPlot._update_plot  s     	::d++C99:::| 	4T73333g...$r   c                 @    |                     d t          g          }|r|d         n|}                     |          } fdt          ddg|          D             }                     |          \  }}}	 j        r||}}d j        v s j        r|nd|d         d<   d j        v s j        r|nd|d         d<   t          j
        d         |                    di                      t          j        d         |                    di                      d S )Nc                     | S r   r   r   s    r   r   z,ElementPlot._update_labels.<locals>.<lambda>  r.  r   r   c           	      H    i | ]\  }}|                     ||          S r   )rU  )r   r  r9   r  r   r   s      r   
<dictcomp>z.ElementPlot._update_labels.<locals>.<dictcomp>  sC     ? ? ?T3 t,,T3cBB ? ? ?r   rl   rm   r  ro  )r   r*   r[  r  r]  rX  r  ru  rv  r^   r  r  r  )
r   r  r   r   r1  r   propsru  rv  rw  s
   ```       r   rW  zElementPlot._update_labels  sK   kkG955%RUUg((,,
? ? ? ? ? ?"%sCj*"="=? ? ?!%!6!6z!B!B 	,#VFF-0DM-A-AT[-A66VXc
< -0DM-A-AT[-A66VXc
< tz!}eiiR.@.@AAAtz!}eiiR.@.@AAAAAr   c           	          |j         r) |j         j        di |                     |||           d S t          di |                     |||          |_         d S )Nr   )ry   r  r  r   rZ  s       r   rX  zElementPlot._update_title  sk    : 	MDJKK 6 6sD' J JKKKKKLL!7!7T7!K!KLLDJJJr   c                 *   | j         d         }ddddd}| j                                        D ]\  }}|                     |||          }||\  }}t	          |t
                    s|g}n|}|d                                         }	||	vrqt          |	          }
t          |
	                    |                    }| j
                            d|d	t          |d                   j        d
|d|           |D ]}t          |||           d S )Nr   colorbarr  r  )cbarr:  xaxesr  r   )r  zCould not find z property on z& model. Ensure the custom option spec z[ you provided references a valid attribute on the specified model. Similar options include )r   backend_optsr	  _parse_backend_optr   r   r   r,   sortedfuzzy_matchr  r  r   __name__setattr)r   r   model_accessor_aliasesoptval
parsed_optmodelattr_accessorr   valid_optionskwsmatchesms                r   _update_backend_optsz ElementPlot._update_backend_opts  s   |F#	"
 "
 )//11 	/ 	/HC00T13 3J!#- E= eT**   "1I0022MM11m444 !?!?@@
"";m ; ;DPQOOD\ ; ;<?; ; 07; ;    / /=#..../9	/ 	/r   c                 r   | j         sd |j        _        d |j        _        d S g dt	          | j                                                  }d |D             }d |D             }d |D             }fdt          |fi |                                D             }fdt          |fi |                                D             }|j        rd|vr|j        d         j	        |d<   |j
        rd|vr|j
        d         j	        |d<    |j        d         j        d	i |  |j        d         j        d	i | d S )
N)rr   bandsr  levelr#  r  c                 D    i | ]\  }}|                     d           ||S ))grid_
minor_grid)r   r   r  r  s      r   r_  z,ElementPlot._update_grid.<locals>.<dictcomp>  s0    VVVA=T0U0UV1VVVr   c                 J    i | ] \  }}d |v 	|                     d d          |!S )xgridgridrI  r}  s      r   r_  z,ElementPlot._update_grid.<locals>.<dictcomp>  2    WWW41a'UV,,7F++Q,,,r   c                 J    i | ] \  }}d |v 	|                     d d          |!S )ygridr  r  r}  s      r   r_  z,ElementPlot._update_grid.<locals>.<dictcomp>  r  r   c                     i | ]9\  }t          fd D                       r                    dd          n|:S )c              3       K   | ]}|v V  	d S r   r   r   rr  r  s     r   r@  z6ElementPlot._update_grid.<locals>.<dictcomp>.<genexpr>  '      .G.G!qAv.G.G.G.G.G.Gr   r{  r  r   rI  r   r  r  rI  s     @r   r_  z,ElementPlot._update_grid.<locals>.<dictcomp>  f     : : :Q ,/.G.G.G.Gw.G.G.G+G+GN7B'''QPQ : : :r   c                     i | ]9\  }t          fd D                       r                    dd          n|:S )c              3       K   | ]}|v V  	d S r   r   r  s     r   r@  z6ElementPlot._update_grid.<locals>.<dictcomp>.<genexpr>
  r  r   r{  r  r  r  s     @r   r_  z,ElementPlot._update_grid.<locals>.<dictcomp>
  r  r   r#  r   r   )	show_gridr  grid_line_colorr  r   	gridstyler	  r  r  r#  r  r  )	r   r   style_itemsr   r  r  xoptsyoptsrI  s	           @r   rY  zElementPlot._update_grid  s   ~ 	)-DJ&)-DJ&FNNN4>//1122VVVVVWW;WWWWW;WWW: : : :!$00%006688: : :: : : :!$00%006688: : :: 	3(%//"jm2E(O: 	3(%//"jm2E(O
1%%u%%%
1%%u%%%%%r   c                    | j         d         }| j         d         }| j         d         }|                     ||||           | j        rd S d}| j        rdnd}| j         d| d                                         D ]\  }}	|                     |||	          \  }
}}
}|                     |||          }| j         d| d
         |         }t          |t                    }| 	                    |	          p| 	                    |           o| j
        }| j        r|s|                     |	||||                     |	d          | j                            |	j        d          ||           d S )Nr  r  r   Frl   rm   r  r  r6  r  r  )r   _update_main_rangesr)  rX  r	  rV  _get_dimension_factorsr   r   model_changed	framewiser  _update_range_get_tagr   r  r   )r   r   rF  r  r  r   r   	multi_dimr  extra_y_ranger  rq  r   rD  extra_scalerK  range_updates                    r   _update_rangeszElementPlot._update_ranges  s   ,y),y)|F#  '7FCCC" 	F 	+4CC	'+|4OY4O4O4O'P'V'V'X'X 	 	#Hm))'6X)NNJAq!Q11'68LLG,'B	'B'B'BCHMK[(33C!%!3!3M!B!B!^dFXFXY]F^F^_ / $ z , q!Wm^<<  !3U;;S)   	 	r   c           
      f   | j         d         }d\  }}}}	t          d ||fD                       r{| j        r| j        r|j        n|j        }
nd }
	 |                     |||
          \  }}}}	n+# t          $ r |                     ||          \  }}}}	Y nw xY w| j        r|||	|f\  }}}}	d\  }}t          d ||fD                       r|                     ||          \  }}| j        }| j	        ot          d | j	        D                       }| 
                    |          p| 
                    |           r|p|p|d u}| 
                    |          p| 
                    |           r|p|s|d uo| j         }|                     |ddd	gd
          }| j        p|                    d          }| j        p|                    d	          }|                    d          p|                    d          }|                    d          p|                    d          }| j        dk    p| j        }| j         d         | j         d         }}t%          |t&                    pt%          |t&                    }t%          |t(                    pt%          |t&                    }d | j        D             }|r)|s|r%|rdnd}| j                            d|z             nD|r#| j         d         }t1          j        |          rt1          j        |          r||z
  nd }t1          j        |          rt1          j        |	          r|	|z
  nd }| j        s	|r|s|s|r| j        pd}| j        dk    rd} n:| j        r| j        dk    r| j        } n |j        r|j        r|j        |j        z  } nd S | j        r;|j        j        |j        j        }"}!|j        j        |j        j        }$}#|"|!z
  |$|#z
  }&}%n||||	f\  }!}"}#}$||}&}%t          d |D                       r|!|"|#|$f\  }}}}	|%|&}}d | j        D             }'t          d |'D                       r	| j        rd S ||| z  z  }(||| z  z  })tA          j!        |(|d          rtA          j!        |)|d          s(t1          j"        |          rt1          j"        |          sn|)|k    r|%|| z  z  })|)|z
  dz  }*||*z
  |	|*z   }	}d}n|&|| z  z  }(|(|z
  dz  }+||+z
  ||+z   }}d}n|r|s| #                    ||          },|j        p|j$        pd }-|j        p|j%        pd }.|s|s	| j&        sd}|r.|.|_        tO          |.|,z            |_        d\  |_$        |_%        n:|r.|-|_        tO          |-|,z            |_        d\  |_$        |_%        n
d!|,z  |_(        |)                    tT          j+        "          }/|)                    tT          j,        "          }0|/rd|/_-        |0rd
|0_.        nt          d# |D                       rd$\  }}| j        r|r1| /                    ||||| j0        | j1        d%         | j2        |           | j        s| j        r|rB| /                    |||	|| 3                    |d&          | j1        d'         | j4        |           d S d S )(Nr   NNNNc              3   N   K   | ] }t          |t          t          f          V  !d S r   )r   r   r   r   rr  s     r   r@  z2ElementPlot._update_main_ranges.<locals>.<genexpr>3  s1      QQz!g{344QQQQQQr   r6  r4  c              3   @   K   | ]}t          |t                    V  d S r   )r   r   )r   ax_ranges     r   r@  z2ElementPlot._update_main_ranges.<locals>.<genexpr>B  s,      TTXz(K00TTTTTTr   c              3   2   K   | ]}|j         o|j        V  d S r   )_triggering	followingr   streams     r   r@  z2ElementPlot._update_main_ranges.<locals>.<genexpr>E  sI       ,J ,J06 -3,>,S6CS ,J ,J ,J ,J ,J ,Jr   rw   rx   Fr  r  r  r  r  equalr  r  c                 <    g | ]}t          |t                    |S r   )r   r7   r   s     r   r   z3ElementPlot._update_main_ranges.<locals>.<listcomp>W  s'    KKKqJq'4J4JKKKKr   r  zdatetime axeszNCannot set data_aspect if one or both axes are %s, the option will be ignored.rA   squarec              3   $   K   | ]}|j         V  d S r   r  r   rss     r   r@  z2ElementPlot._update_main_ranges.<locals>.<genexpr>y  s$      >>"r~>>>>>>r   c                 <    g | ]}t          |t                    |S r   )r   r6   r   s     r   r   z3ElementPlot._update_main_ranges.<locals>.<listcomp>  s'    SSSa:a;R;RSSSSr   c              3   $   K   | ]}|j         V  d S r   r  )r   sss     r   r@  z2ElementPlot._update_main_ranges.<locals>.<genexpr>  s$      =="r~======r   g?)rtolr8  Tro   g      ?r4  c              3   $   K   | ]}|j         V  d S r   r  r  s     r   r@  z2ElementPlot._update_main_ranges.<locals>.<genexpr>  s$      88B888888r   )FFr   r  r   )5r   r   r  rX  r   rV  rW  _get_factorsr  r   r  r'  r  r  r  r  r  r  r   r   r   r   r  r  r+   	is_numberr  r  rg   ri   r  r   rd  allcloserR  
get_aspectrw   rx   r  r)  r  rE  r   rF  r   rG  rH  r  invert_xaxisr   r`  r  ra  )1r   r   r  r  rF  r   rp  rq  rr  r   	range_dimxfactorsyfactorsr  r   xupdateyupdateri  fixed_widthfixed_heightconstrained_widthconstrained_heightr  r  r  r  rM  range_streamsr  xspanyspanratioframe_aspect	current_l	current_r	current_b	current_tcurrent_xspancurrent_yspansize_streamsdesired_xspandesired_yspanypadxpadr  rw   rx   r   scroll_zooms1                                                    r   r  zElementPlot._update_main_ranges/  sv   |F#+
1aQQw>PQQQQQ 	(| !,0,<NGLL',		 	?!--gv-SS
1a ? ? ? "--gv>>
1a?  (1aZ
1a'(TT'7ASTTTTT 	D!%!2!27F!C!CHhN	^ J ,J ,J:>.,J ,J ,J )J )J	++G44P8J8J48P8PQ 1"/i+d* 	 ++G44P8J8J48P8PQ 1"/iI4<D4HgRVRfNf 	 ((&7H:MX](^^'?7;;w+?+?)BW[[-B-B#KK44PK8P8P$[[66S'++l:S:S{g-A1A|G,dl7.Cu 88^Juo<^<^e\22Xj6X6XKKDLKKK ]	,K ]	,8 ]	,'2GmmGJ  -/6 7 8 8 8 8  X	,<'D>!,,L1B1BLAaCCE>!,,L1B1BLAaCCEz J2k J2l J2@Q J2Ug J2 (-A;(**#$LL[ T[G%;%;#';LL& 4+; #'#4T5E#ELL F: @+/<+=t|?OyI+/<+=t|?OyI4=i4G9U^K^=MMABAq!>Iy)Y38%=M>>>>>>> @
 "+Iy)!KJAq!Q#0-5ESS4<SSS======= $-  F %u\'9 : %u\'9 :[DAAA #[DAAA#u--#26-2F2F# "e++$153E$FM)%/3DT61T6qA"GG$153E$FM)%/3DT61T6qA"GG" 2{ 266(=DJ=#*@dk@S# (| (T_ (#'L 	2(.D%'*6&='9'9D$.8+DJ  2',D$(+E&L(9(9D%.8+DJ(*6	D%{{(9{::H++5+>+??K -(,% 1+0(88-88888 	,+GWz 	SW 	Sw1h8I#|N;TY	S S S
 	d2 	w 	Axw)O)O^,di    	 	s   A. .%BBc                 `    |j         D ]%}t          |t                    r||v r
||         c S &dS )zGet a tag from a Bokeh model

        Args:
            model (Model): Bokeh model
            tag_name (str): Name of tag to get
        Returns:
            tag_value: Value of tag or False if not found
        F)r   r   r  )r   rp  tag_nametags       r   r  zElementPlot._get_tag  sE     : 	% 	%C#t$$ %S8}$$$ur   c	                    t          |t                    r2t          t          |                    }|r|d d d         }||_        d S t          |t
          t          f          r| j        sd S t          |t          j	                  rn||k    r|t          |t          j
                  rHt          j        dd          }	t          j        |          t          j        |          }}||	z  }||	z  }n t          |r|dz  nd          }	||	z  }||	z  }|r)|j        |j        f}t          j        ||f|g          \  }}|r||}}t          |t          j
                  sI|rG||dk    r?|dk    rdndt          j        |          d	z
  z  }| j                            d
|z             i }
t          j        |          r|j        |f|
d<   |
d         |
d<   t          j        |          r|j        |f|
d<   |
d         |
d<   |
                                D ]n\  }\  }}t          |t          j	                  rt/          |          } |j        di ||i |r,|                    d          s|                    |||           od S )Nr;  r{   r,  g?r0  r   g{Gz?rn   r:   zLogarithmic axis range encountered value less than or equal to zero, please supply explicit lower bound to override default of %.3f.rg   reset_startri   	reset_endreset_r   )r   r   r   rR   rD  r   r   apply_rangesr+   rQ  rg  rd  timedelta64
datetime64absrg   ri   rU  log10r  r  rR  r	  rQ   r  r   trigger)r   r  lowhighrD  invertsharedrK  r   rs  updatesr  oldnews                 r   r  zElementPlot._update_range  s   j+.. 	<0011G.2w!(JF:'=>> 	4CT 	Fc4,-- 	Tkkco#t233 T22M#..d0C0CTv4SWW55v 	> &
7FdV'<==IC(tS3#t233 	B 	BPSWXPXPX++$$2q0@+ACJ;=@AB B B = 	6 * 0#6GG%,W%5GM"= 	2(nd3GEN#*5>GK $]]__ 	0 	0MAzS#t011 +%c**J((3((( 0h!7!7 0""1c3///	0 	0r   c                 (   t          | t                    s	| j        sdS | j        dS | j        }|dk    rd}d}nd}d}| j        sd\  }}nUt          | j        t
                    r-| j        |         }t          |t
                    r|\  }}n||}}n| j        | j        }}t          d| d| d	| d
| d| d| d| d| d| d| d| d| dd| j        i          }| j                            d|           | j	        
                    |           dS )z|
        Sets up a callback which will iterate over available data
        renderers and auto-range along one axis.
        Nrl   r   rm   rA   r   r   a  
        const cb = function() {

          function get_padded_range(key, lowerlim, upperlim, invert) {
            let vmin = range_limits[key][0]
            let vmax = range_limits[key][1]

            if (lowerlim !== null) {
             vmin = lowerlim
            }

            if (upperlim !== null) {
             vmax = upperlim
            }

            const span = vmax-vmin
            const lower = vmin-(span*z')
            const upper = vmax+(span*a  )
            return invert ? [upper, lower] : [lower, upper]
          }

          const ref = plot.id

          const find = (view) => {
            let iterable = view.child_views === undefined ? []  : view.child_views
            for (const sv of iterable) {
              if (sv.model.id == ref)
                return sv
              const obj = find(sv)
              if (obj !== null)
                return obj
            }
            return null
          }
          let plot_view = null;
          for (const root of plot.document.roots()) {
            const root_view = window.Bokeh.index[root.id]
            if (root_view === undefined)
              return
            plot_view = find(root_view)
            if (plot_view != null)
              break
          }
          if (plot_view == null)
            return

          let range_limits = {}
          for (const dr of plot.data_renderers) {
            const renderer = plot_view.renderer_view(dr)
            const glyph_view = renderer.glyph_view

            let [vmin, vmax] = [Infinity, -Infinity]
            let y_range_name = renderer.model.y_range_name

            if (!renderer.glyph.model.tags.includes('no_apply_ranges')) {
              const index = glyph_view.index.index
              for (let pos = 0; pos < index._boxes.length - 4; pos += 4) {
                const [x0, y0, x1, y1] = index._boxes.slice(pos, pos+4)
                if (z	0 > plot.z_range.start && z	1 < plot.z6_range.end) {
                  vmin = Math.min(vmin, z+0)
                  vmax = Math.max(vmax, z1)
                }
              }
            }

            if (y_range_name) {
              range_limits[y_range_name] = [vmin, vmax]
            }
          }

           let range_tags_extras = plot.a  _range.tags[1]
           if (range_tags_extras['autorange']) {
             let lowerlim = range_tags_extras['y-lowerlim'] ?? null
             let upperlim = range_tags_extras['y-upperlim'] ?? null
             let [start, end] = get_padded_range('default', lowerlim, upperlim, range_tags_extras['invert_yaxis'])
             if ((start != end) && window.Number.isFinite(start) && window.Number.isFinite(end)) {
               plot.z\_range.setv({start, end})
             }
           }

          for (let key in plot.extra_z6_ranges) {
            const extra_range = plot.extra_a  _ranges[key]
            let range_tags_extras = extra_range.tags[1]

            let lowerlim = range_tags_extras['y-lowerlim'] ?? null
            let upperlim = range_tags_extras['y-upperlim'] ?? null

            if (range_tags_extras['autorange']) {
             let [start, end] = get_padded_range(key, lowerlim, upperlim, range_tags_extras['invert_yaxis'])
             if ((start != end) && window.Number.isFinite(start) && window.Number.isFinite(end)) {
              extra_range.setv({start, end})
              }
            }
          }
        }
        // The plot changes will not propagate to the glyph until
        // after the data change event has occurred.
        setTimeout(cb, 0);
        r   )codeargsrangesupdate)r   r&  r  r  paddingr\  r	   r  js_on_eventr   r   )r   r9   didxodimp0p1padcallbacks           r   _setup_autorangezElementPlot._setup_autorange  s   
 $,, 	T5F 	F>!Fn#::DDDDD| 		0FBe,, 	0,t$C#u%% "BBcB\4<B  b"  ')!b" b"" ')#b" b"t ub" b"t %)ub" b"t ;?ub" b"t JNub" b"v *-wb" b"x *-yb" b"L *-Mb" b"X Yb" b"` '*ab" b"b -0cb" b" b"D 4:&Eb( b( b(F 	
~x888"))(33333r   c                 L     j         r|ddd         }dd         ddd          fddD             }t          |          D ]]\  }||         }t          |         t                    r5t          |t                    s|j        j        dvrfd|D             ||<   ^dS )a  
        Transforms non-string or integer types in datasource if the
        axis to be plotted on is categorical. Accepts the column data
        source data, the columns corresponding to the axes and the
        dimensions for each axis, changing the data inplace.
        Nr;  r:   c                 0    g | ]}j         | d          S )r  )r   )r   r  r   s     r   r   z0ElementPlot._categorize_data.<locals>.<listcomp>  s&    ==="$,"}}}-===r   xySUc                 F    g | ]}                              |          S r   pprint_value)r   r  r   is     r   r   z0ElementPlot._categorize_data.<locals>.<listcomp>  s+    EEET!W11!44EEEr   )rX  	enumerater   r   r   dtypekind)r   r  colsr   rF  colcolumnr  s   `  `   @r   _categorize_datazElementPlot._categorize_data  s      	"":D8DDbD>D=======oo 	F 	FFAs#YF6!9k22 FFD))F-3\->d-J-JEEEEEfEEES			F 	Fr   c                 2   d| j         v r1| j        j        r%| j        j        r| j        j        | j        j        z  S | j        r||z  | j        z  S | j        dk    r||z  S | j        dk    rdS | j        | j        S | j        | j        | j        | j        z  S dS )z7
        Computes the aspect ratio of the plot
        r   r  r  rA   )r   r  r  r  r  r  rw   rx   )r   r  r  s      r   r  zElementPlot.get_aspect  s     T\!!dj&<!AX!:)$**AAA 	%K!111[G##;[H$$1[$;Z#(?:dk))1r   c                 *   j         rj         nGd|                    j        i           v r|j                 d         n|                    d          t	          j                  | j        sj        j        dv rng fdD             S )NrD  Fr  c                 Z    g | ]'}j         j        d v r|n                    |          (S )r  )r  r  r  )r   r  r7  r  s     r   r   z6ElementPlot._get_dimension_factors.<locals>.<listcomp>  s;    ^^^RSV\&$..I4J4J14M4M^^^r   )	r  r  r   r  rd  asarray_allow_implicit_categoriesr  r  )r   r   rF  r7  r  s      `@r   r  z"ElementPlot._get_dimension_factors  s     	@%FF&**Y^R8888IN+I6FF--i??FF##. 	A%|0D88VVbF^^^^^W]^^^^r   c                     |                                 dd         \  }}|                     |||          }|                     |||          }||f}| j        r|ddd         }|S )z3
        Get factors for categorical axes.
        Nr:   r;  )r   r  rX  )r   r   rF  xdimr  xvalsyvalscoordss           r   r  zElementPlot._get_factors  su     ''))"1"-
d++GVTBB++GVTBB2fTTrTlVr   c                 d    | j         d         j        D ]}g |j        dd<   d|_        d|_        dS )z>
        Disables legends if show_legend is disabled.
        r   Nr   )r   legendr	  border_line_alphabackground_fill_alpha)r   rp  s     r   _process_legendzElementPlot._process_legend  sI     f%, 	( 	(AAGAAAJ"#A&'A##	( 	(r   c           
         | j         rdndg|d<   t          |          }| j                            | j        rdnd          }t          |t                    r|t          | j                           }d|v rd|v r|d= | j	        d         j
        |j        v r| j        s| j	        d         j
        |d	<   | j	        d
         j
        |j        v r| j        s| j	        d
         j
        |d<   d|vr-|                    d          p|                    d          |d<   | j        r| j	        d
         }t          | j        t                    r5|j        d         d         }| j        dz  }t%          ||z
  ||z             }n't%          | j        d         | j        d                   }|                    |j        |j        |t+          di |          } t-          ||          di t%          |fi |}	|	|	j        fS )/
        Returns a Bokeh glyph object.
        r  no_apply_rangesr   r   singlelegend_fieldlegend_labelr  x_range_namer  y_range_namer   rA   r'  r8  )rg   ri   r   )x_sourcex_targety_sourcey_targetr   )r  rF   _plot_methodsr  r   r   r\  r)  rX  r   r   r  r'  r  r)  r   r   rY  r  subplotr  r   r  glyph)
r   r   mappingr   plot_methody_source_rangerh   rs  ytarget_ranger  s
             r   _init_glyphzElementPlot._init_glyph  s*    .2->U>>DUV!*--
(,,$,-TYYHUUk5)) 	=%c$*:&;&;<KZ''Nj,H,H>*<	"'4+>>>tG[>)-i)@)EJ~&<	"'4+>>>tG[>)-i)@)EJ~&##!+!?!?!a:>>R`CaCaJv" 	!\)4N$.55 a',Q/0AB1"4 $6&=fVm L L L $4+?+BH\]^H_ ` ` `<<' 11=11	    D .74--LLZ0K0K70K0KLL''r   c                 2    |                     ||d          S )NTrF  flat)apply)r   	transformr   rF  s       r   _element_transformzElementPlot._element_transform  s    wvDAAAr   c           
      0    t          |          }|r|dz   ndt          |                                          D ]9\  }t          t                    rt	          |          dk    r0|v r#t          |                                        nt          |t                    r1|j        v r(t          |j                                                nMt          fd j
        D                       r-t          t          fd j
        D                                 t          t
                    r||                    |          s                    |          sFj         j
        vr8|                    |            j                            d| dd           sj         j
        v rbt%          d	  j
                                        D             t'           j
                            }                    ||d
          d         }	n                     ||          }	t-          j        |	          sJt1          t-          j        |	                    dk    r%d|vst	          d|	          s	| j        v r|	d         }	t-          j        |	          s| j        v rIt7          |          j        }t;          d                    |j        | j        j                             |rt1          |	          t1          t          tC          |"                                                              k    rbt          |tF                    rtI          j%        |	d          }	n7t          |tL                    r t          |tN                    s|	d d         }	no|dk    rtI          j(        |	          }	n|)                    d          rpt-          j        |	          r(t          |	tT                    rt                    dz   }	n4t          |	tH          j+                  r|	j,        j-        dv rd |	D             }	t-          j        |	          r|	}
n|dk    r|nd|i}
|	||<   t          |	t,          j.                  o|	j,        j-        dv }|/                    dz             }d|v rt          |	t,          j.                  r|s&t	          d|	          rt          |t                     rui }|	j,        j-        dvrta                    }||v rd||         v r||         d         }nt-          j        |	          }t          |	t,          j.                  r*|	j,        j-        dk    r|1                    t                    }||d<     j2        ||t          |          f|dz   |d|}|}t          |tf                    }|r|	j,        j-        d v rF|d!z   }j        |v r |                    j                  j4        nt          fd"|	D             ||<   tk           d#d$          r5tk           d%d$          rd| d&}fd'|	D             ||<   ||d(<   n||d(<   ||d)}
|
||<   ;t'          |                                          D ]\  }}	d*D ]}|z   |k    s||vst	          ||	d          r!t           fd+ j6        D                       }d, tn          D             dgz   D ]}|z   d-z   |z   }|/                    |          }|d.v r|d/k    s	| j6        vr6|d0k    }|t	          ||d          r	|s|r|	||<   |z   d1z   |z   }|/                    |          }|r|}|t	          ||          r|r||s|	||<   |S )2Nr  r  Tc              3   $   K   | ]
}|k    V  d S r   r   r   r  r  s     r   r@  z0ElementPlot._apply_transforms.<locals>.<genexpr>  s'      99!A999999r   c              3   (   K   | ]}|k    |V  d S r   r   r2  s     r   r@  z0ElementPlot._apply_transforms.<locals>.<genexpr>  s'       F FqA F Fr   z
Specified z dim transform z? could not be applied, as not all dimensions could be resolved.c                 $    i | ]\  }}|j         |S r   rE  r2  s      r   r_  z1ElementPlot._apply_transforms.<locals>.<dictcomp>  s     NNNDAqafaNNNr   r+  r   rA   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.)styler9   r   r  r%   r;  angle	font_sizeptifuc                 L    g | ]!}t          t          |                    d z   "S )r9  )rH  r)  r   s     r   r   z1ElementPlot._apply_transforms.<locals>.<listcomp>)  s)    9993s1vv;;t+999r   node_markerfielduifMmbcmapifMurD  rq  _color_mapper)r   r6  ifMub_str__c                 &    g | ]} |          S r   r   )r   r  r1  s     r   r   z1ElementPlot._apply_transforms.<locals>.<listcomp>M  s!    &A&A&Ayy||&A&A&Ar   show_legendFlegend_labels_labelsc                 <    g | ]}                     ||          S r   )r  )r   r  rF  s     r   r   z1ElementPlot._apply_transforms.<locals>.<listcomp>R  s)    0V0V0VQ1B1B1a1H1H0V0V0Vr   r  r=  r.  )alphar5  c              3   v   K   | ]3}|                     d z             odk    pt          dd          V  4dS )filledge_filledTN)r   r  )r   oprefixr   s     r   r@  z0ElementPlot._apply_transforms.<locals>.<genexpr>^  se       $. $. LL//hVw5F5g'RVX`bfJgJg$. $. $. $. $. $.r   c                     g | ]}|d z   S )r  r   r   r:  s     r   r   z1ElementPlot._apply_transforms.<locals>.<listcomp>a  s    AAA!#AAAr   fill_)nonselection_muted_rJ  hover_line_)8r  r	  r   rH  rJ   r9   rb  r1   rT  r   r   r
  r   appliesr7  popr  r  r'   r   r-  r/  r+   isscalarr   unique_array_nonvectorized_stylesr   rj  
ValueErrorformatr  r  r  r  r4   rd  tiler2   r0   deg2radendswithr)  r=  r  r  arraylike_typesr  r?   astype_get_colormapperr   r  r  
style_optsrG   ) r   r   r  rF  r6  r6  	new_styler  dsrn  r  numericcolormapr  	range_keyrD  cmapperr=  r  label_fieldr   supports_fillpprefixfill_key
fill_styler   line_key
line_styler1  rF  rP  r  s    `                           @@@@r   _apply_transformszElementPlot._apply_transforms  s   KK	#+sKK%%'' f	 f	DAq!S!! HAq>>T))'\\G11!4455AA// HA4F4FGM77::;;AA9999t'899999 HD F F F FD,= F F FFFGGAq#&& 5+<Q\\RWEXEX+<ii(( Q[@Q-Q-Qa   
""? ? ?1 ? ? ?@ @ @ {d///NND4E4K4K4M4MNNN!$"3446 6ggbdg;;A>--a&AAM#&& 3t/@/E/E+F+F!+K+K""hw&<&<"dF`A`A`!f=%% !222"7mm4G$ &Q
 RXQW/0ak7151F RX RH RHI I I  !c#hh#d43F3F.G.G*H*HHH!';77 ! gc1oo#GT22 !:gx;X;X !!#2#h G||jooK(( :=%% :*S#*>*> :a&&+CCRZ00 :SY^u5L5L99S999C}S!!  --aaGQ<Q !d&:;;Z	RZ@ZGyy//H1C1E!F!F  (# 6 6 :DXt:T:T 9>// -a 0 0I F**yF9<M/M/M"("3I">"&"3C"8"8!#t';<< 6SVAVAV").."5"5(/F9%/$/7F04UGBCOBS6;G G?EG G (2HII >y~00 !H;'11(/(=(=ak(J(J(WII(+I&A&A&A&AS&A&A&AUt]E:: >(/ou(M(M( >*<e*<*<*<K0V0V0V0VRU0V0V0VD-8CIn558=In5 %G<<IaLL y0011  	2  	2JE3' 2 2!8u$$T(9(9Xad=S=S(9 # $. $. $. $. $.!_$. $. $. !. !.  BA/@AAA2$F 2 2G%g~g5a7H!*x!8!8J !$???ALL#4?::  $x/E#+J0M0M+V[+) ,.1	(+%g~g5a7H!*x!8!8J % !)?  $/Xa5L5L/UZ/#+M+.1	(+322B r   c                     t          ||          }| j        rS| j        r7d                    d | j                                        D                       }n|j        }|r| j        r||d<   |S )N)source, c                 B    g | ]\  }}|                     |d           S )T)
print_unitr  r2  s      r   r   z1ElementPlot._glyph_properties.<locals>.<listcomp>  s8     $? $? $?41aANN1N$F$F $? $? $?r   r  )r  rE  r   joinr	  r=  r(  )	r   r   r   ru  rF  r6  r6  r   r  s	            r   _glyph_propertieszElementPlot._glyph_properties  s    %///
 	4  ' $? $?$($5$;$;$=$=$? $? $? @ @ ! 4$- 4-3
>*r   c                    t          |          }|r|dfndD ]dD ]@}|                    |z             }|d|z   |vsr||d|z   <   |d|z   |vsr||d|z   <   Afd|                                D             }| j        rt          |fi |}z|                    |           fd|                                D             S )Nr  r  )r5  rJ  rW  rS  c                 p    i | ]2\  }}|                               |t                    d          |3S r   )r   r   )r   r  r  gtypes      r   r_  z2ElementPlot._filter_properties.<locals>.<dictcomp>  sM     - - -41aU++-Qs5zz{{^Q - - -r   c                 $    i | ]\  }}|v 	||S r   r   )r   r  r  alloweds      r   r_  z2ElementPlot._filter_properties.<locals>.<dictcomp>  s$    EEEAW1r   )r  r  r	  r   r  )	r   r   
glyph_typer  glyph_propsprop
glyph_propr`  r~  s	      `    @r   _filter_propertieszElementPlot._filter_properties  s5   :&&*4?z2&&% 	* 	*E* ; ;'^^E$J77
)wt|;/N/NRW/N0:K-)wt|;/N/NRW/N0:K-- - - -;3D3D3F3F - - -E| *"588K88""5))))EEEE!2!2!4!4EEEEr   c                    |                                 }t          |          }t          |fi |}d}	|	D ]}
|                    |
d           }| nt	          |j                                                  }g }dD ]}|rzt          ||dz   d           }|dk    r`|j        }|	                                } t          |          di d |                                D             }t          ||dz   |           |r|s|r|                     |||          }|                                }|D ]}t          |                    |                    }t          t          ||                    }t#          |t                    r|                    d          n|}t#          |t                    r|                    d          n|}|||vs||j        v s||k    r|                    |           |                    ||f           |dnt'          ||          }|sJ| j        s|                     ||           t-          | d          r| j        |                     |           n| j        r| j        j        d	k    }t9          | j        d
|          5  d |D             }t;          | j        |d|d          }| j        j        j                            |           d d d            n# 1 swxY w Y   || j         j!        D ]}|j        D ]}||j"        v rtt#          |t                    r|}nU|
dk    rd|
v rdnd}||i}nBt#          |j#        t                    r$tI          tK          |j#                            |i}nd|i}||_#        |D ]\  }}  |j&        di |  |!|r!| j        s|                     ||           d S d S d S d S )N)r  r  )r  
selection_rT  rV  rU  r$  rL  c                 8    i | ]\  }}t          |          ||S r   )r\   r}  s      r   r_  z-ElementPlot._update_glyph.<locals>.<dictcomp>  s?     0H 0H 0HA7CA0H1 0H 0H 0Hr   r=  Tselectedservercollect)r  c                     i | ]}|g S r   r   )r   cs     r   r_  z-ElementPlot._update_glyph.<locals>.<dictcomp>  s    555a555r   r  empty)documentrp  attrr  setterr  r=  valuer   )'r   rF   r  rY  r   r  r   r  r$  r   r   r	  rk  r  	dataspecsr]   r  r   r   rO   r   _update_datasourcehasattrr  _update_selectedr  r  r   rX   r   r   _held_eventsr  r  	renderersr=  r
  r  r  )!r   r  r   r%  r$  ru  r  allowed_propertiesmergedlegend_propslpr  columnsglyph_updatesr  
base_glyphr`  filteredr  specnew_specold_spec	new_field	old_fieldcds_replacer  
empty_dataeventlegitemr=  r  r  s!                                    r   _update_glyphzElementPlot._update_glyph  s   "--//!*--
j,,G,,7 	 	BZZD))F! "v{''))**Q 	4 	4J A*W*<dCCF??!)J&==??E,D,, I I 0H 0H 0H 0H 0H I IEHj&8%@@@  j ..vzCUVVH ))I! * *+HLL,>,>??+GE4,@,@AA5?$5O5O]HLL111U]	5?$5O5O]HLL111U]	Lit&;&;yFK?W?W[dhq[q[qy))))  %!23333
 #ldd0B640P0P 	C% 6''555tZ(( .T]-F%%f---] 	C]'83FT]IfEEE 	C 	C55W555
)!] ""   '4;;EBBB	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C z( + +I + +D4>11%fd33 6$*EE8^^.5mm77D%)6NEE'
D99 6%)$tz*:*:%;%;V$DEE%,f$5E%*
+ + 	# 	#ME6EL""6""""D4F##FD11111 s   A
K11K58K5c                 l   | j                             d          }|dS t          |j        t                    sd|j        v r|j                                        D ]\  }}d|z  t          |          r t          |d         t          j
                  sEt          |          rXt          |d         t          j                  r8|d         j        j        dk    r"fd|j        D             |_        d|j        <   |j        d	k    rg |_        ||j        vr|j                            |           dS dS )
z
        Attaches renderer to hover tool and processes tooltips to
        ensure datetime data is displayed correctly.
        r   Nr   r   r   Mc                 4    g | ]\  }}||k    r|d z   n|fS ){%F %T}r   )r   rp  fr  s      r   r   z2ElementPlot._postprocess_hover.<locals>.<listcomp>  s3    %e%e%edaQRqc!I++q&I%e%e%er   rM  rL  )r   r  r   r   rH  r   r  r	  r   r+   rg  rd  r=  r  r  
formattersr  r   )r   r  ru  r   r  r  r  s         @r   _postprocess_hoverzElementPlot._postprocess_hover  sC   
   ))=F%.#.. 	7<5:3M3M#[..00 7 7	6k[[7%/q	4;N%O%O7[[7%/q	2:%F%F7KQRS9?K_cfKfKf%e%e%e%eV[Vd%e%e%eEN,6E$S)?f$$ EO5?**O""8,,,,, +*r   c           	          | j         r|j        n|}| j         rEt          |                    d t          g                    }|                     ||          \  }}}	n4| j        | j                 }	|                     |||	          \  }}}	|j	        }t                      5  |                     ||||	          }	d d d            n# 1 swxY w Y   ||                     |          }|| j        d<   |x| j        d<   | j        d<   |j        | j        d<   |                     |||||	          }
d|
v rd|v r|                    d           t                      5  |                     |||
          \  }}d d d            n# 1 swxY w Y   || j        d<   t%          |t&                    r
|| j        d	<   |                     ||           t                      5  |                     ||
||||j                   d d d            d S # 1 swxY w Y   d S )
Nc                     | j         S r   _plot_idr   s    r   r   z*ElementPlot._init_glyphs.<locals>.<lambda>      !* r   previous_idru  cdsr  r  r  r$  glyph_renderer)r   r   r\  r   r*   get_batched_datar6  cyclic_indexget_datar  r.   rs  _init_datasourcer   r  rz  rY  r)  r   r   r  r  r  )r   r   r   rF  ru  style_element
current_idr  r%  r6  r   r  r$  s                r   _init_glyphszElementPlot._init_glyphs  s"   (,A' < 	*w//0D0DwiPPQQJ#'#8#8&#I#I D'55Jt01E#'==&%#H#H D'5 )J"$$ 	I 	I**7D&%HHE	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I >**400F&0]#7==Xe!4#)?Z ++D-QVWW
Z''Ng,E,EKK'''"$$ 	J 	J"..tWjIIOHe	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J %Wh)) 	6-5DL)*&111 #$$ 	Z 	ZxWeVV[YYY	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Zs6   CCCE>>FF HH
Hc                 6  
 |                      |          dd         }| j        r|ddd         n|\  
t          
t                    rE
j        |j        v r7|j        
j                 }
fd|j        D             }|r|n|j        d         }n|j        }|j        d         }t          t                    rEj        |j        v r7|j        j                 }fd|j	        D             }|r|n|j	        d         }	n|j
        }|j	        d         }	||	f||ffS )zR
        Looks up the axes and plot ranges given the plot and an element.
        Nr:   r;  c                 4    g | ]}|j         j        k    |S r   )r  r   )r   r  rl   s     r   r   z*ElementPlot._find_axes.<locals>.<listcomp>3  (    SSSue6HAF6R6RU6R6R6Rr   r   c                 4    g | ]}|j         j        k    |S r   )r  r   )r   r  rm   s     r   r   z*ElementPlot._find_axes.<locals>.<listcomp>:  r  r   )r[  rX  r   r(   r   r  r  r  r  r  r  )r   r   r   rt  r  re  x_axisr  r  y_axisrl   rm   s             @@r   
_find_axeszElementPlot._find_axes+  s>    ''00!4	"&"2Ay2	1a## 	#$2E(E(E)!&1GSSSS
SSSE$4ee$*a8FFlGZ]Fa## 	#$2E(E(E)!&1GSSSS
SSSE$4ee$*a8FFlGZ]F'7!333r   c                    | j         r/d | j        j                                        D             d         }n| j        j        }t          j        | j        j                  }|                     | j        ||          }|| _	        || _
        || _        | j         r|j        n|}t          j        ||          }|/|                     ||||          }|                     |           n|                     ||          \  }}	|\  | j        d<   | j        d<   |	\  | j        d<   | j        d<   | j        r5|j        |j        v r'|j                            |j                  | j        d<   || j        d	<   | j        r|                                  |                     ||||           | j        s-|                     |||           |                     ||           | j        D ]}
|
                                 | j        r|                                  | j        s>|                     |           |                                   | !                    |           | "                    |           d
| _#        |S )zN
        Initializes a new plot object with the last available frame.
        c                     g | ]}||S r   r   rS  s     r   r   z/ElementPlot.initialize_plot.<locals>.<listcomp>G  s    BBBbrBrBBBr   r;  NrF  r  r  r  r  r  r   T)$r   r   r  r  r   r+   
wrap_tuplelast_keycompute_rangesr   r@  current_key
match_specr  r  r  r   r)  r=  r  rY  r  r  r  r(  r[  r  r   
initialize	top_level
init_linksr  r  _setup_data_callbacks_execute_hooksr  )r   rF  r   r  ru  r   r  r  r!  plot_rangesr   s              r   initialize_plotzElementPlot.initialize_plotA  s{   
 < 	%BBDIN$9$9$;$;BBB2FGGinGodi011$$TYV<<$$(,A'77<??3fE?RRD''---- $g > >D+;?8DL!4<#8?J<DL#T\)%<& [ &$*===.2.A.E.EmFY.Z.ZDL+#V> 	$!!###$888} 	7c4777v666. 	 	BMMOOOO> 	OO} 	-""4(((  """&&t,,,G$$$
r   c                     | j         sd S |                    dt          i          D ]F}|j        }| j         D ]5}||j                            dg           vr|                    d|           6Gd S )Nr   zchange:datar  )r   rE  r   data_sourcejs_property_callbacksr  js_on_change)r   r   r  r  r   s        r   r  z!ElementPlot._setup_data_callbacksu  s    ) 	FV]$;<< 	1 	1H&C0 1 1S6::="MMMM$$VR0001	1 	1r   c           	         | j         d         }| j                             d          }| j         d         }i }| j                             dd           }| j        r+t          |                    d t
          g                    }	n|j        }	|	| j         d<   | j        o|	|k    | _        | j        r| 	                    ||          \  }
}}n| 
                    |||          \  }
}}| j        rb|j                                        D ]H\  }}||
vr||
|<   t          |
|                   s$t          |j                  r|j        |         |
|<   It                      5  |                     ||
||          }d d d            n# 1 swxY w Y   |r|                     |||||          }| j                             d          }d|v rt#          |d          r|d         |_        t                      5  |                     ||||||
           d d d            d S # 1 swxY w Y   d S | j        s|                     ||
           d S d S )Nr   r$  ru  r  c                     | j         S r   r  r   s    r   r   z,ElementPlot._update_glyphs.<locals>.<lambda>  r  r   r  r  )r   r  r   r\  r   r*   r  dynamicr   r  r  r  r	  r   r.   rs  rz  r  r  r  r  )r   r   rF  r6  r   r$  ru  r%  r  r  r  r  r  r   r  s                  r   _update_glyphszElementPlot._update_glyphs~  s   |F#  ))h' l&&}d;;< 	*w//0D0DwiPPQQJJ )J&0]#"lJ
k0I< 	I#'#8#8&#I#I D'55#'==&%#H#H D'5  	-))++ - -1D==DGGT!W -#fk*:*: -$k!nDG"$$ 	I 	I**7D&%HHE	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I  	2//gvvuUUJ|''(899HE!!gh	&B&B!#(#3 &(( W W""8Z%QUVVVW W W W W W W W W W W W W W W W W W# 	2##FD11111	2 	2s$   F  FF/HHHc                     | j         s	 dS )zK
        Resets RangeXY streams if norm option is set to framewise
        TN)
r(  r   rh  ri  r  r   r   r7   r  r   )r   r1  r   r  rN  r   s         r   _reset_rangeszElementPlot._reset_ranges  s     = 	 	Fr   c                    |                                   t          | j        t                    o| j        p| j        }| j        | _        |s||                     |          }n||| _	        || _        | j
                            dd          }| j
                            dd          }|du}t          |d          r||_        t          |d          r||_        | j        r|rG|E| j        s| j        s7| j        r2| j        d         j        | j        j        u r| j        d         j        sdS | j        r
|j        }	d}
n|}	| j        j        }
|                     |	d          }|
r|                    |
          n|| _        | j        s|                     | j        ||          }n| j                            |            | j        j        di |                     |	d          j         t;          j        |	|          }|| _        | j
        d         }| j        s^|                      |	|           | !                    |||	           | "                    |           | #                    |           d| _$        d	| j
        v rA| %                    |           d
| j
        v r#| j
        d
         }| &                    ||           | '                    ||| j        | j(                            | )                    |           dS )zV
        Updates an existing plot with data corresponding
        to the key.
        Nr  r$  r  r   r6  r   Tr   r  r   )*r  r   r   r)   r(  r   r@  
prev_frame
_get_framer  r   r  r  r  r  r   r   r  r  r   r6  _max_cyclesrh  
max_cyclesr  rF  r  r  ri  r+   r  r   r  r[  r  r  r   r  r  r  r  r  )r   r  rF  r   r   reusedr  r$  r  r  r  r6  r  s                r   update_framezElementPlot.update_frame  s   
 	DIz22V8U- 	)'/ooc**GG "D!(D<##$4d;;  $//%8Y'' 	'&H5)$$ 	$#EM\ 	' 	godloW[Wbo^ /> $q 1 6$:L:Q Q QZ^ZhijZkZw QF< 	0#LMJJ#M/J##M7;;5?JU%%j111U
} 	'((C@@FFKv&&&
OOD//vFFNOOO77$|F#} 	!v666c4777""4(((&&t,,, DMdl""w'''$$l5)''#666GVTZ8I-JKKKG$$$$$r   c                     t          | |           t                                          |           |                                  d S r   )rS   r   r  rv  )r   r   r   s     r   r  zElementPlot._execute_hooks  sC    tW%%%w'''!!#####r   c                     d |                      d           D             }d |D             }t          fd|D                       S )z
        Determines if the bokeh model was just changed on the frontend.
        Useful to suppress boomeranging events, e.g. when the frontend
        just sent an update to the x_range this should not trigger an
        update on the backend.
        c                     g | ]	}|D ]}|
S r   r   )r   cbsr   s      r   r   z-ElementPlot.model_changed.<locals>.<listcomp>  s<     $ $ $C"$ $  $ $ $ $r   c                     | j         S r   )r   r   s    r   r   z+ElementPlot.model_changed.<locals>.<lambda>  s    1; r   c                 >    g | ]}|j         D ]}|j        	|j        S r   )r   	_metadata)r   r   r  s      r   r   z-ElementPlot.model_changed.<locals>.<listcomp>  sR     I I I)+I I%v7GI6+ I I I Ir   c              3   t   K   | ]2}|                                 D ]}|d          j        d          k    V  3dS )idN)r  ref)r   r   mdrp  s      r   r@  z,ElementPlot.model_changed.<locals>.<genexpr>  sb       . .6#]]__. . d8uy. . . . . . . .r   )r   r   )r   rp  r   stream_metadatas    `  r   r  zElementPlot.model_changed  s    $ $4==1F1F#G#G $ $ $	I Ii I I I . . . ._ . . . . . 	.r   c                      d                       d           D             }t          j        |          }t           fd|D                       S )z
        Property to determine whether the current frame should have
        framewise normalization enabled. Required for bokeh plotting
        classes to determine whether to send updated ranges for each
        frame.
        c                 Z    g | ](}|r|                     d  t          g          ng D ]}|)S )c                     | S r   r   r   s    r   r   z2ElementPlot.framewise.<locals>.<listcomp>.<lambda>  s    ! r   )r   r*   )r   r  r1  s      r   r   z)ElementPlot.framewise.<locals>.<listcomp>  s[     4 4 4()&2QZZgY%G%G%G/14 4   4 4 4 4r   c                     | j         S r   )r@  r   s    r   r   z'ElementPlot.framewise.<locals>.<lambda>  s    ao r   c              3   t   K   | ]2}                     |d           j                            d          V  3dS )rN  r  N)rh  ri  r  )r   framer   s     r   r@  z(ElementPlot.framewise.<locals>.<genexpr>  sX       0 0 &&uf55=AA+NN 0 0 0 0 0 0r   )r   r+   r   r   )r   current_framess   ` r   r  zElementPlot.framewise
  sz    4 4dmm4M4M&N&N 4 4 4 -n== 0 0 0 0 .0 0 0 0 0 	0r   r   r4  )Fr  NNN)hrj  
__module____qualname__r  Listr  ObjectSelectorr  r  Numberr  	Parameterr  Dictrf  r  Integerrw   rx   r  r  r  r  r  r  r  Booleanr  ClassSelectorr   r\  r'  rY  r  r  r  r  r  r  rj  r   r   r  rH  r   r   rA  rB  rB  r  r\  r   r^  r_  _stream_datar   r   r   r  r  r$  propertyr)  r|  r  r  r  r  r  r  rU  r[  rW  rX  rv  rY  r  r  r  r  r  r  r  r  r  r  r)  r/  rs  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  __classcell__r   s   @r   rc   rc   `   s       5:d 1C D D DL !E :T:T:T [G H H HE %$T;K;K;K RH I I II
 U\" +' ( ( (F U_T 	0 	 	 	F 5:b /> ? ? ?L %,t 2   K EM#$y OG H H HE U]34	 PI J J JF  %-i VG H H HK !5=$y WI J J JL d9 CN O O OI tI DP Q Q QJ d9 CN O O OI tI DP Q Q QJ U_T 07 8 8 8F
 emE 0   G *e)%u T7 8 8 8O
 '%,qUb iQ R R R &%e=]=]=]^^^Ju'8T QR S S SH 
2 ,- . . .I
 uz3* 33 4 4 4H %*+/CA AG<= = =C t 2D E E EJ  %- 3+ , , ,K EJ (= (= (=8: : :M EJr (6 7 7 7E #e"7,N ,N ,N("# # #G %$c=,? F12 2 2J %$c=,? F12 2 2J L!%  MM L     (4 4 4L L L L\6 6 6A A A A$$ $ $L * * X* IM&*Tt0 t0 t0 t0 t0l? ? ?Bj j j jX& & &P"9 "9 "9H  = = = ;?$(k k k kZ       B B BM M M&/ &/ &/R& & &*  8P P Pd  ,0 ,0 ,0 ,0\A4 A4 A4FF F F$  &
_ 
_ 
_	 	 	( ( ($( $( $(LB B BN N N Nb
 
 
 
F F F&M2 M2 M2`- - -.#Z #Z #ZJ4 4 4,2 2 2 2h1 1 1&2 &2 &2R& & &&9% 9% 9% 9%x$ $ $ $ $. . . 0 0 X0 0 0 0 0r   rc   c                   4    e Zd ZdZi Zg ZddZd Zd Zd Z	dS )CompositeElementPlotzi
    A CompositeElementPlot is an Element plot type that coordinates
    drawing of multiple glyphs.
    Nc           
      ^   d ||fv r-| j         | j                 }|                     |||          \  }}}t          t	          |fi || j                  }i }	|j        }
|
| j        d<   |D ]B}| j        	                    d
                    |                    d          d d                             }t	          |          }|	                    |i           }t                      5  |                     |||||          }d d d            n# 1 swxY w Y   t          |          |	v r|	t          |                   }n'|                     |          }||	t          |          <   || j        |dz   <   |                     ||||||          }|                     |||	                    |i                     }t                      5  |                     ||	                    |i           ||          \  }}d d d            n# 1 swxY w Y   || j        |dz   <   t'          |t(                    r|| j        |dz   <   |                     ||           t                      5  |                     |||	                    |i           |||j                   d d d            n# 1 swxY w Y   Dt1          | dd          rmt3          | j                                                  D ]H\  }}|                    d	          s|                     |||                    d	d
                     Gd S d S )Nr  r  r;  _source_glyph_glyph_rendererrc  Fcolor_mapperr  )r6  r  r  rW   r  _draw_orderr  r   _style_groupsr  ry  splitr.   rs  r  r  rz  _process_propertiesr)  r   r   r  r  r  r  r   r	  ra  _draw_colorbarrI  )r   r   r   rF  ru  r  r%  r6  r   source_cacher  r  style_groupgroup_styleds_datar   r  r$  r  r  s                       r   r  z!CompositeElementPlot._init_glyphs&  s   D'?""Jt01E#'==&%#H#H D'540000$2BCC%
&0]# 	8 	8C,00#))C..":M1N1NOOKu++KhhsB''G&(( i i"44Wgv{\ghhi i i i i i i i i i i i i i i'{{l**%bkk2..w77,2R[[)*0DLY'//gvv{\ghhJ11#z7;;sTVCWCWXXJ&(( ` `"&"2"24S"9M9Mz[^"_"_%` ` ` ` ` ` ` ` ` ` ` ` ` ` `).DLX&(H-- ?6>S!223##Hf555 '(( 8 8""8ZS"9M9Mu#)6;8 8 88 8 8 8 8 8 8 8 8 8 8 8 8 8 8 4U++ 	LT\//1122 L L1zz.11 ##D!QYY~r-J-JKKKK		L 	LL Ls6   'DD	D	0HH		H	 4J  J$	'J$	c                    d|v r0d                     |                    d          d d                   n|}| j        |         }i }|                                D ]r\  }}|| j        v r_|                    d          d         }||k    r=||v r||         }d                     |                    d          dd                    }nm|||<   s|S )Nr  r;  r   rA   )ry  r  r  r	  re  )	r   r  r   r%  r  group_propsr  r  r6  s	            r   r  z(CompositeElementPlot._process_propertiesS  s    /2czzchhsyy~~crc*+++s(-$$&& 		 		DAqDO##QK''G||#AJabb!122AAKNNr   c           
         | j         d         }| j                             dd           }| j        r+t          |                    d t
          g                    }n|j        }|| j         d<   | j        o||k    | _        | 	                    |||          \  }}}t          t          |fi || j                  }	|	D ]}
|                    |
          }| j         |
dz            }| j                             |
dz             }|r2t          |          }| j                            d                    |
                    d          d d                             }t!                      5  |                     |||||          }d d d            n# 1 swxY w Y   |                     ||||||          }|                     |
|||
                   }| j                             |
dz             }t!                      5  |                     ||||
         |||           d d d            n# 1 swxY w Y   z| j        s||                     ||           d S )	Nr   r  c                     | j         S r   r  r   s    r   r   z5CompositeElementPlot._update_glyphs.<locals>.<lambda>j  r  r   r  r  r  r;  r  )r   r  r   r\  r   r*   r  r  r   r  rW   r  r  r  ry  r  r.   rs  rz  r  r  r  )r   r   rF  r6  r   r  r  r  r%  r   r  gdataru  r$  r  r  r   r  s                     r   r  z#CompositeElementPlot._update_glyphsd  s   |F# l&&}d;;< 	*w//0D0DwiPPQQJJ )J&0]#"lJ
k0I#}}WfeDDgu40000$2BCC 	7 	7CHHSMME\#i-0FL$$S\22E 7"5kk"044SXXciinnSbS>Q5R5RSS*,, k k"&"8"8%Q\^i"j"jKk k k k k k k k k k k k k k k!33D'66S^`kll
!55c:ws|TT
<++C0A,ABB*,, = =&&xWS\',fe= = == = = = = = = = = = = = = = = ' 7E,=''666!	7 	7s$   (FF	F	;!H((H,	/H,	c           	          t          |          }d                    |                    d          dd                   } t          ||          di t	          |fi |}||j        fS )r  r  Nr;  r   )rF   ry  r  r  r  r$  )r   r   r%  r   r  r&  r  s          r   r)  z CompositeElementPlot._init_glyph  sq     "*--
hhsyy~~crc233-74--LLZ0K0K70K0KLL''r   r  )
rj  r  r  __doc__r  r  r  r  r  r)  r   r   r   r  r    ss          M K*L *L *L *LZ  "7 7 7B( ( ( ( (r   r  c                       e Zd ZdZdddiddddiddddd	dd
ddd	ddddiddddiddddd	ddddd	ddZ ej        deee	fd          Z
 ej        deeefd          Z ej        dd          Z ej        ej        ej        fdd          Z ej        deeefd          Z ej        dg dd          Z ej        dd           Z ej         ee          dd!"          Z ej        i d#          Z ej        i d$          Z ej        dd%          Z  ej        d&d'          Z! ej        dd(          Z" e#d)d*d)+          Z$d,Z%e&d-d.gz   Z'd7d0Z(	 	 d8d2Z)	 	 d9d4Z*d5 Z+ fd6Z, xZ-S ):ColorbarPlota]  
    ColorbarPlot provides methods to create colormappers and colorbar
    models which can be added to a glyph. Additionally it provides
    parameters to control the position and other styling options of
    the colorbar. The default colorbar_position options are defined
    by the colorbar_specs, but may be overridden by the colorbar_opts.
    r   locationr  )r  r  r   r   
horizontal)r$  orientationr   rh   	top_righttop_leftbottom_leftbottom_right)r   r   r  r  r'  r(  r)  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.rt   z5
        Formatter for ticks along the colorbar axis.z{
        An explicit override of the color bar label. If set, takes precedence
        over the title key in colorbar_opts.rd   r:   z
        User-specified colorbar axis range limits for the plot, as a tuple (low,high).
        If specified, takes precedence over data and dimension ranges.)re   lengthrf   Fz
        Percentile value to compute colorscale robust to outliers. If
        True, uses 2nd and 98th percentile; otherwise uses the specified
        numerical percentile value.linear)r,  rK  eq_histz?
        Color normalization to be applied during colormapping.rj   z'
        Whether to display a colorbar.z
        Allows selecting between a number of predefined colorbar position
        options. The predefined options may be customized in the
        colorbar_specs class attribute.rk   re   rf   a   
        Allows setting specific styling options for the colorbar overriding
        the options defined in the colorbar_specs class attribute. Includes
        location, orientation, height, width, scale_alpha, title, title_props,
        margin, padding, background_fill_color and more.a  
        Dictionary to specify colors for clipped values, allows
        setting color for NaN values and for values above and below
        the min and max value. The min, max or NaN color may specify
        an RGB(A) color as a color hex string of the form #FFFFFF or
        #FFFFFFFF or a length 3 or length 4 tuple specifying values in
        the range 0-1 or a named HTML color.z5
         Whether to apply log scaling to the z-axis.Tai  
        If ``cnorm='eq_hist`` and there are only a few discrete values,
        then ``rescale_discrete_levels=True`` decreases the lower
        limit of the autoranged span so that the values are rendering
        towards the (more visible) top of the palette, thus
        avoiding washout of the lower values.  Has no effect if
        ``cnorm!=`eq_hist``.z<
        Whether to make the colormap symmetric around zero.black   )bar_line_colorlabel_standoffr  z#8b8b8br?  paletter  c           	      V   t           rt          |t                     rd S t          |t                    rt          |          }n=t          |t                    r|j        dk    rt                      }nt                      }t          | j	        | j
                           }|d         }t          d t          ||g           D                       rd S | j        r!| j                            d| j        i           | j        /| j                            dt#          | j        d          i           dD ]L}|                     |d	
                              d          }|| j                            d|i            nMdD ]L}	|                     |	d	
                              d          }
|
| j                            d|
i            nMt          |d         f||d| j        }t+          di t          |fi | j        }|                    ||           || j        |dz   <   d S )N)mapperr   r  c              3   @   K   | ]}t          |t                    V  d S r   )r   r   )r   rp  s     r   r@  z.ColorbarPlot._draw_colorbar.<locals>.<genexpr> 	  s,      OOuz%**OOOOOOr   ry   r1  r  )cticksr  Fr   r  r  )clabelrO  title_text_font_sizer  )r  r#  rc  r   )r   r   r
   r   r   r  r    r   r  colorbar_specscolorbar_positionr   r  r8  colorbar_optsr  
cformatterra   r  r  _colorbar_defaultsr   r  r   )r   r   r  rP  r#  	cbar_optsr  tkrM  lbrL  r  	color_bars                r   r  zColorbarPlot._draw_colorbar  sh   ! 	j?U&V&V 	Fl$566 	#!666FFn55 	#,:JQ:N:N[[FF ]]F,T-CDEE	 OOc28N8NOOOOO 	F; 	>%%w&<===?&%%{N4?TW4X4X&YZZZ% 	 	B~~b~77;;JGGH#"))+G*RSSS $ ' 	 	Br%88<<ZHHI$"))+A9*MNNN % If% /L / /-/ /@@tD??D,>??@@		3'''*3VJ&'''r   r  c	                 	    |d S t                    }	 j        r] j                            fd          }
fd|
D             }
|
r.|
d         \  }s|r|d         r	|d         nd S  j        d<   S d S |d nt	          |          }rt          d  j        D                       r j        \  }}n|	|v r j        rd||	         v r||	         d         \  }}n||	         d         \  }}||	         d         \  }}t          j	        |d	
          r\t          j	        |d	
          rFt          j	        |          r2t          j	        |          rt          |          t          |          }}nKt          t                    rt          j        t          j        }}n|                    j                  \  }} j        r"t%          t'          |          |          }| |}}t          j         j        d                   r j        d         n|}t          j         j        d                   r j        d         n|}nd\  }}|dn|dz   }|p,|                    |dz   |                    dd                    d  j                                        D             t          t0                    r{t3                    } fd|D             }t          t                    r1j        |v r |                    j                  j        nt:          nj        fd|D             }n|d u}t           j        t                    r j        }nzt           j        t2                    r`t	           j                  dz
  }t          t2                    r4t	                    |k    r!t?          d|t	                    fz            tA          ||          }t           j        t2                    rtC          | j        ||f          \  }\  }} "                    |||          \  }} j                                      Bj#        |k    r|_#        fd|                                D             }|r j$        di | n |dd|i| j        <    j        d<   S )Nc                     | j                             d          | j                                       d | j                                         D             fS )N	color_dimc                 <    g | ]}t          |t                    |S r   )r   r   rJ  s     r   r   zCColorbarPlot._get_colormapper.<locals>.<lambda>.<locals>.<listcomp>*	  s6     ; ; ;!)![99;A ; ; ;r   )r   r  r  )rl   r   s    r   r   z/ColorbarPlot._get_colormapper.<locals>.<lambda>(	  sT    19==559==..; ;qy'7'7'9'9 ; ; ;< r   c                 ,    g | ]\  }}}|k    ||fS r   r   )r   cdimr?  mapperseldims       r   r   z1ColorbarPlot._get_colormapper.<locals>.<listcomp>-	  s4     * * *,?D$5== w(==r   r   r  c              3   >   K   | ]}t          j        |          V  d S r   )r+   rR  )r   cls     r   r@  z0ColorbarPlot._get_colormapper.<locals>.<genexpr>>	  s,      994=$$999999r   robustr3  r  T)int_likerA   r4  r  r  r?  viridisc                 4    i | ]\  }}|t          |          S r   )rH   r}  s      r   r_  z1ColorbarPlot._get_colormapper.<locals>.<dictcomp>Y	  s$    PPP41aaAPPPr   c           	      n    g | ]1}                     |                     d j                            2S )NaN)r  _default_nan)r   r  r?  
nan_colorsr   s     r   r   z1ColorbarPlot._get_colormapper.<locals>.<listcomp>\	  s9    ^^^QRtxx:>>%9J#K#KLL^^^r   c                 &    g | ]} |          S r   r   )r   r  r1  s     r   r   z1ColorbarPlot._get_colormapper.<locals>.<listcomp>d	  s!    555yy||555r   zwThe number of colors in the colormap must match the intervals defined in the color_levels, expected %d colors found %d.)r  )clipc                 D    i | ]\  }}t          |          |k    ||S r   )r  )r   r  rm  rk  s      r   r_  z1ColorbarPlot._get_colormapper.<locals>.<dictcomp>y	  s=     3 3 3vq#w**c11 s111r   r3  rE  r   )%r?   r  r   r   r   r>  climclim_percentiler+   is_intr)  r   r9   rd  r  ranger   	symmetricmaxr  rR  r  clipping_colorsr	  r  r   r7  rb  r  rH  color_levelsr]  r@   r=   _get_cmapper_optsr3  r  )r   rJ  r   rF  r6  rD  colorsr6  r   dim_namecmappersrI  ncolorsr  r  dlowdhighsym_maxrP  r3  r  colormapperr  r?  rk  r1  rT  s   ``      `              @@@@r   rd  zColorbarPlot._get_colormapper	  sl    =V^4 '' = 	}--< < < < H* * * *8 * * *H 
$,QK  $ $71: $")!*#t/6^,t!/$$s7|| 	#99ty99999 6 I	TTV##' =Hx8H,H,H &x 0 :IC &x 0 <IC$X.v6eKd333 4Kt4444K%%4 K&&4 !$C#d))CE3'' 6FBFT#MM%*55	T~ .c#hh--$HgT"&-	!"="=F$)A,,3C#'=1#>#>H49Q<<DDD"IC}%)O6&=%))FI2N2NOOPP43G3M3M3O3OPPP
dD!! 	e4jjG^^^^^^V]^^^G%%% /?g-- ' 5 5eo F F SII #II!.	5555W555GG!-K$+S11 =+D-t44 =d/0014dD)) =c$ii7.B.B$ &R )0T';&< = = = #4kJJJG$+T22 e'6w@QY\^bXc'd'd'd$#t 223gzRRT,""4(('))")3 3 3 3 3 3 3D '&&&&&!k::':T::G!(DL(-DL%r   r5  c                 t   i i }	}|                     | j                  |                    |d           }
rMt          |
t                    r|
|v st          |
t
                    r| j                            d|z             d s||	fS |                              }t          j
        j                  }|rdnd}|ct          |t                    s|j        j        |v r@t                    }||v rd||         v r||         d         }nt          j        |          }|/|r-|j        j        dk    r|dz  }d |D             }d |D             }|                     |||||          }|*t          |t$                    r|dz  }fd	|D             }d
}|||<   || j        r||	d<   ||d|	|<   ||	fS )NzaCannot declare style mapping for '%s' option and declare a color_index; ignoring the color_index.iOSUOSUrD  r  rC  c                 ,    g | ]}t          |          S r   rH  r   r  s     r   r   z0ColorbarPlot._get_color_data.<locals>.<listcomp>	  s    +++SVV+++r   c                 ,    g | ]}t          |          S r   rm  rn  s     r   r   z0ColorbarPlot._get_color_data.<locals>.<listcomp>	  s    ///!s1vv///r   c                 :    g | ]}                     |          S r   r  )r   r  rH  s     r   r   z0ColorbarPlot._get_color_data.<locals>.<listcomp>	  s'    999aT&&q))999r   Tr  rI  )rb  color_indexr  r   rH  r9   r  r  r  r+   r   r   r   r  r  r?   r[  rd  r   rE  )r   r   rF  r6  r   rD  ra  int_categoriesr  r%  r5  cdatar=  dtypesrj  r5  rH  s                   @r   _get_color_datazColorbarPlot._get_color_data	  s+   Bg$$T%566		$%% 	j,, 	'1A1AjQVX[F\F\1AJC   D 	!= ((..(33)4u?
5$ 7 7?5;;Kv;U;U%d++IF""yF94E'E'E +I6+E22>ek6F#6M6MXE++U+++E//w///G&&tWfe'.8 8?z&2HII?XE99995999EGU4#3&+GN#"'f==W}r   c                    |i }| j         dk    rt          }| j         dk    s| j        rvt          }t	          j        |          r&t	          j        |          r|dk    rd}dvrdd<   nit	          j        |          r |dk    r| j                            d           n4| j         dk    r)t          }t          t          d	          k    r
| j        |d
<   t          |t          t          j        f          rt#          |          }t          |t          t          j        f          rt#          |          }||k    r| j        dz  }||z  }||z  }t	          j        |          r||d<   t	          j        |          r||d<   g d}|                    fd|D                        nBt*          }t-          |          }t/          t1          |                    }dv rd         |d<   ||fS )Nr,  rK  r   rA   minzrgba(0, 0, 0, 0)zLog color mapper lower bound <= 0 and will not render correctly. Ensure you set a positive lower bound on the color dimension or using the `clim` option.r-  z2.4.2rescale_discrete_levelsr:   r  r  ))rR  	nan_color)r]  
high_color)rw  	low_colorc                 0    i | ]\  }}|v 	||         S r   r   )r   r   rm  ra  s      r   r_  z2ColorbarPlot._get_cmapper_opts.<locals>.<dictcomp>	  s)    YYYytS$RX..fTl...r   )rD  rR  ry  )cnormr   logzr   r+   rZ  r  r  r  r
   rN   r$   rx  r   r   rd  bool_r)  default_spanrR  r  r   rR   r  r   )	r   r  r  rD  ra  r  rh  rs  
color_optss	       `    r   r`  zColorbarPlot._get_cmapper_opts	  s   ?DzX%%/zU""di",;s## D(9(9 cQhhCF**(:u^C(( SAXXJ&&-   y((/ 77#3#3336:6RD23#bh/00@C#$rx 011C#d))4d{{*Q.v}S!! "!U}T"" $#V\\\JKKYYYYJYYYZZZZ0K"7++GW...D$*5M[!D  r   c           	      6   t                                          |||          }| j        rmt          | j                                                  D ]F\  }}|                    d          s|                     |||                    dd                     G|S )zQ
        Returns a Bokeh glyph object and optionally creates a colorbar.
        r  r  )	r   r)  rc  r   r   r	  ra  r  rI  )r   r   r%  r   retr  r  r   s          r   r)  zColorbarPlot._init_glyph	  s     gg!!$<<= 	LT\//1122 L L1zz.11 ##D!QYY~r-J-JKKKK
r   r|  )NNNr  )r5  NNF).rj  r  r  r!  r:  r  r  r)  r   r[  r_  rH  r   r   r=  Stringr8  Tuplerd  r  rX  r'  r   rY  r   r}  r  rc  r;  r  r<  r^  r~  rx  r\  r  r>  rS  rC   r\  r  rd  ru  r`  r)  r	  r
  s   @r   r#  r#    s         ,3-7,@$B $B+1,6v+>$@ $@+29?;G-I -I$J $J ,38>;G-I -I$J $J .6/9;.G&I &I-5/9:.F&H &H-5;H>J/L /L&M &M /7;I>J/L /L'M 'M#N NN* '5&tS$<N UH I I IL %$c=,? F89 9 9J U\$ -0 1 1 1F 5;/ @J K K KD *e)%eT@R Y' ( ( (O !E ;W;W;W ^B C C CE u}U 1* + + +H -,TT.5I5I5< C+, , , EJr 0< = = =M !ej 20 1 1 1O 5= -8 9 9 9D ,emD ?  ! ! ! e 2? @ @ @I WQ4;= = = L+vy.AA'4 '4 '4 '4T TX*8d d d dN Z^',) ) ) )X*! *! *!Z
 
 
 
 
 
 
 
 
r   r#  c                      e Zd Z ej        ddd          Z ej        dd          Z ej        dd	          Z	 ej
        d
d          Z ej        g ddd          Z ej        i d          ZdddddZddZdS )
LegendPlotr   rp   z&
        Number of columns for legend.rs   Nz
        Label overrides.rd   FzB
        Controls whether the legend entries are muted by default.r  z
        If legend is placed outside the axis, this determines the
        (width, height) offset in pixels from the original position.)r'  r(  r)  r*  r   r   r  r  r'  z
        Allows selecting between a number of predefined legend position
        options. The predefined options may be customized in the
        legend_specs class attribute.r.  zB
        Allows setting specific styling options for the colorbar.r   r   r   r   )r   r   r  r  c                    |p| j         d         }|j        sd S |j        d         }d | j                                         D             }t          |          }|s| j        st          |j                  dk    s| j        sg |j        d d <   d S | j        r| j        |j        _	        n| j        rdnd|j        _
        | j        }|| j        v rQg |j        d d <   | j        |_        |dv r| j        sd|j        _
        |                    || j        |                    n||_        |j        D ]4} |j        di | j         |j        D ]}|j        D ]}| j        |_        5d S )	Nr   r   c                 <    g | ]}t          |t                    |S r   )r   r   )r   rk  s     r   r   z.LegendPlot._process_legend.<locals>.<listcomp>
  s>     C C C *@AACG C C Cr   rA   r%  verticalr  r  r   )r   r  r  r   r(  r   r	  rE  legend_colsnrowsr&  legend_positionlegend_specslegend_offsetr$  r  r  legend_optsr  legend_mutedmuted)	r   r   r  rc  r  r  r  r  rr  s	            r   r  zLegendPlot._process_legend
  s   +t|F+{ 	FQC C4<+>+>+@+@ C C C8nn 	4T] 	4s6<7H7HA7M7M# 8N FLOOO [$($4!!:>:J*Z,,PZ'&Cd'''!#AAA"&"4+++D4D+.:DK+(9#(>????"% { 4 4
..T-...I 4 4D!^ 4 4"&"3444 4r   r   )rj  r  r  r  r  r  r  rF  r  r  NumericTupler  r   r  r  r  r  r   r   r   r  r  	  s*       %-) B) * * *K EJt 2   M !5= 5E F F FL 'E&v <H I I IM +e* 4E 4E 4E =H9)
* 
* 
*O %*R .E F F FK &G L 4  4  4  4  4  4r   r  c                       e Zd ZdZdS )AnnotationPlotzR
    Mix-in plotting subclass for AnnotationPlots which do not have a legend.
    N)rj  r  r  r!  r   r   r   r  r  0
  s           r   r  c                       e Zd Z ej        dd          Zed eD             z   ez   ddgz   Z	 ej        dd          Z
g dZ fd	Zed
             Zed             Z fdZddZd Zd Zd Z fdZddZddZ xZS )r&  Fz<
        Whether to display overlaid plots in separate panesrd   c                     g | ]}d |z   S )border_r   rR  s     r   r   zOverlayPlot.<listcomp>;
  s    &L&L&Lqy{&L&L&Lr   r  r  zH
        Whether to split the legend for subplots into multiple legends.)3rw   rx   r  r  r  r  r  rX  r  r  r`  ra  r<  r  r  r9  r:  r  r  r  r  sizing_modery   title_formatr  r  r  r  r  r  ru  rv  xlimr  zlimrA  rB  r  r  r  r  r  r  r  r  r  r  r  	fontscaler'  rY  c                     |                      |d          j                            dd          | _         t	                      j        |fi | d| _        d S )Nr   r  F)rh  ri  r  _multi_y_propagationr   r   )r   overlayr  r   s      r   r   zOverlayPlot.__init__O
  s]    $($7$7$H$H$P$T$TU^`e$f$f!++F+++$)!!!r   c                     | j                                         D ]%}t          |j        t                    s	|j        c S &| j        S r   )rk  r  r   r^  r   r   r  s     r   r^  zOverlayPlot._x_range_typeT
  O    %%'' 	' 	'Aaow77 '&&&'!!r   c                     | j                                         D ]%}t          |j        t                    s	|j        c S &| j        S r   )rk  r  r   r_  r   r  s     r   r_  zOverlayPlot._y_range_type[
  r  r   c           	      Z     j         d         }                     d  fdg          }t          d |D                       }d |D             } j        r4t	          |j                  dk    st	          |          dk    r) j        s"|s t                                                      S |j        sd S |j        d         }i } 	                     j
        j        d           j                 }|                                D ]\  }	}
|	t          v rDd	|	vr@|	                    d
          }d
                    |d d         d	z   |dd          z             }	|	t"          v rd|	z   }	|	                    d          r
|	dd          }	|
||	<    j        }|dv r j        sd|d<   |0|j        r)d                    d |j        D                       }||d<   |                                         dd                     |                                         dd                      j        r|                    d j        i            |j        d#i | | j        v r j        |         }n||_        d j         vr
g  j         d<    j         d         }d |D             }|j        D ]}t5          |j                  }t9          |t:                    r.t=          t?          |                                                    n|}|r+t9          |t:                    r|                     dd          s||v rA||         }tC          tE          j#        |j$        |j$        z                       |j$        d d <   |||<   |%                    |           | j         d         vr  j         d         %                    |           g }g |D ]}fd|j$        D             |j$        d d <   ||v s%|j$        rt          d |j$        D                       sIt5          |j                  }t9          |t:                    r5d|v r1 j&        r*|d         }d j&                             ||          i|_        |j$        z  |%                    |           tC          tE          j#        |                    |j        d d <    j'        rtQ          ||           |)                    d           }g }|j        D ]y}t9          |j        t:                    r	d|j        v r|%                    |           ;tU          d#i t;          ||g!          } j+        |_        |,                    ||           z|r=tU          d#i t;          ||!          } j+        |_        |,                    ||           g |j        d d <   n6|d"v r2tQ          ||            j+        |_        |,                    ||           |j        D ];} |j        d#i  j-         |j        D ]}|j$        D ]} j.        p|j/        |_/         <d S )$Nr   c                     | S r   r   r   s    r   r   z-OverlayPlot._process_legend.<locals>.<lambda>d
  s    1 r   c                     | uS r   r   )rl   r   s    r   r   z-OverlayPlot._process_legend.<locals>.<lambda>d
  s    $ r   c              3   r   K   | ]2}t          |t                    t          |t                    ,|d uV  3d S r   )r   r  r&  rR  s     r   r@  z.OverlayPlot._process_legend.<locals>.<genexpr>e
  sZ       ; ;Q(J77;)![99;1D= ; ; ; ; ; ;r   c                 J    g | ] }t          |t          t          f          |!S r   )r   r  r&  rR  s     r   r   z/OverlayPlot._process_legend.<locals>.<listcomp>h
  sB     H H H$Q(EFFH! H H Hr   r   rA   r6  liner  label_legend_   r  r%  r&  rv  c                     g | ]	}|j         
S r   r=  r?  s     r   r   z/OverlayPlot._process_legend.<locals>.<listcomp>
  s    >>>1qw>>>r   ry   r  label_text_font_sizelegend_titler9  ncolslegend_itemsc           	          i | ]q}t          t          |j                  t                    r@t	          t          t          |j                                                                      n|j        |rS r   )r   r]   r=  r  r\  rh  r	  )r   r  s     r   r_  z/OverlayPlot._process_legend.<locals>.<dictcomp>
  sx     
 
 
  *1733T::HE&)!'2288::;;<<<@A
 
 
r   r  Tc                     g | ]}|v|	S r   r   )r   rr  r  s     r   r   z/OverlayPlot._process_legend.<locals>.<listcomp>
  s#     Q Q Qqay>P>P>P>P>Pr   c              3   6   K   | ]}|j         pd |j        v V  dS )	hv_legendN)r  r   r  s     r   r@  z.OverlayPlot._process_legend.<locals>.<genexpr>
  s0      SSq	:[AF%:SSSSSSr   Fr   )r	  )r   r   r   r   r   )0r   r   r   rE  r   r  r  r   r  rh  r   r   r  r	  rE   r  ry  rI   r   r  r  r   r  r  r  r$  r]   r=  r   r  r\  rh  r  r   r+   r   r  r   rF  multiple_legendsr_   r   r   r  r  r  r  r  )r   r  r   rk  legend_plotsnon_annotationr  ri  r   r  r  ksplitr  ry   r  rF  r  
item_labelr=  	prev_itemr  legend_group
new_legendr  rr  r  r   s   `                        @r   r  zOverlayPlot._process_legendb
  s   |F#==/F/F/F/F.GHH ; ;( ; ; ; ; ;H HX H H H  	C$4$4$9$9  A%%t|%|%77**,,, 	FQ((AA$BST
$$&& 	 	DAqO##aHHVBQBZ.vabbz9::O##qL||I&& abbEGAJJ"###D,<#%1GM"7=II>>>>>??E$GGt~~h0FGGHHHt~~n6LMMNNN 	8NNGT%56777     $####C(CC!FO--+-DL(|N3
 
 "
 
 

 L 	> 	>D)$*55J9CJPT9U9UeE&!1!1!3!344555[eE Z
D99 *..QXZ^B_B_ %%)%0	)-d.B9CVW[WeCe.f.f)g)g	#AAA&&'+e$##D)))t|N;;;L077=== 	  
	" 
	"D Q Q Q QDN Q Q QDN111   SSDNSSSSS !)$*55J*d++ M:0E0E$J\0E"7+%t'9'='=eU'K'KL
'IOOD!!!!t3H==>>QQQ  	)$'''666NNJL 1 1!$*d33 w4:7M7M ''---#EEd:dV&D&D&DEE
&*&8
#
C0000 1#KKd:\&J&J&JKK
&*&8
#
C000 FLOO777$'''"0FOOOFC((( ; 	; 	;CCJ**)***	 ; ; ; ;A"/:17AGG;;	; 	;r   Nc                 .   |g }i }g g }}| j                                         D ]\  }}|                    |          }||                    || j                  }	|	D ]}
t          |
t                    rt          j        |
          }nt          |
          }t          |
t          j
                  r(|
j        rt          |
j                  nd}||v rw|
||<   n||v r|                    |           |                    |
           || j        d<   |S )r   Nr   r   )rk  r	  r  r   r   r   rH  rL   r   r   r   r   r\  r   r   )r   r   r   r   
init_tools
tool_typesr  r#  r1  el_toolsr   r  r   s                r   r   zOverlayPlot._init_tools
  s>    I!#RJ
 M//11 	, 	,LCS!!B~"..r4>BB$ , ,D!$,, /$.N4$8$8		$(JJ	!$88 	5;?=#P5#7#7#7b#{22$48K11"j00 ")))444%%d++++&1]#r   c                 J   | j         r d|j        v r|j        d         | j        d<   dS d|j        v rd| j        v r|j        d         }|j        r9t          |j        t                    st          d |j        D                       }nd}| j        d                             |          }|rv|j        dk    rg n|j        }|j        dk    rg n|j        }d ||z   D             }t          t          j
        |                    |_        d| j        vr|| j        d<   dS dS dS dS dS )zI
        Merges tools on the overlay with those on the subplots.
        r   r   c              3   L   K   | ]\  }}||                     d d          fV   dS )r  r  Nr  )r   r   r  s      r   r@  z+OverlayPlot._merge_tools.<locals>.<genexpr>
  s9       f ft$Y(C(C!D f f f f f fr   r   rL  c                     g | ]}||S r   r   r  s     r   r   z,OverlayPlot._merge_tools.<locals>.<listcomp>  s    ZZZ1AMQMMMr   N)r   r   r   r   rH  r\  r  r  r   r+   r   )r   r#  r   r   r   tool_renderershover_renderersr  s           r   _merge_toolszOverlayPlot._merge_tools
  s]    < 	1Gw66$+OG$<DL!!!''MT\,I,IOG,E~ j&E&E   f fW\We f f fff<.228<<D 1'+~'?'?T^(-6(A(A""uZZ(HZZZ	!%d&:9&E&E!F!F$,..,0DL))) (',I,I1 1
 /.r   c                    g }| j                                         D ]\  }}|j                            |          }||j        r|                    ||          s?|                    |          }t          j        ||          }	|	                    ||	|          }
t          |
          r|                    |
           t          t          j        t          |                     S r   )rk  r	  r  r  r  _has_axis_dimensionrb  r+   r  r  r   r   r   r   r   )r   r  rF  r7  rD  r  r  r1  r9   elrangesfss              r   r  z"OverlayPlot._get_dimension_factors
  s    ]((** 	# 	#EAr!!!$$Bzz8N8NrS\8]8]z""9--Cr622H**2x==B2ww #r"""D(99:::r   c                    g g }}| j                                         D ]\  }}|j                            |          }|vt	          j        ||          }|                    ||          \  }	}
t          |	          r|                    |	           t          |
          r|                    |
           t          t	          j
        t          |                     }t          t	          j
        t          |                     }||fS r   )rk  r	  r  r  r+   r  r  r   r   r   r   r   )r   r  rF  r  r  r  r  r1  r  xfsyfss              r   r  zOverlayPlot._get_factors  s    (]((** 	) 	)EAr!!!$$B~?2v66??2x88Ss88 )OOC(((s88 )OOC(((,UH-=>>??,UH-=>>??!!r   c                     t          | j                                                  }|r|d                             |          S t	                                          |          S )Nr   )r   rk  r  r[  r   )r   r   rk  r   s      r   r[  zOverlayPlot._get_axis_dims&  sV    ,,..// 	7A;--g666ww%%g...r   c           
      H   | j         r| j        rt          d          | j        rz| j        j                            d d g          }t          d |D                       rt          d          t          t          |                    dk    rt          d          t          j
        | j        j                  }d | j        j                                        D             }|st          d	          |d
         \  }}|                     | j        ||          }| j        p/t          d | j                                        D                       | _        |<| j        s5| j        s.|                     ||||          }|                     |           || j        d<   |r4| j        s-|                     |||           |                     ||           g }	| j                                        D ]\  }}
d }| j        rd|
_        |
                    |||          }t7          |t8                    r$|                    |d           }||
_        ||
_        | j        r
|| j        d<   | j        rX|
                     |d          }|stC          ||| j        j                  }|	"                    tG          ||                     | $                    |
           | j        r>tK          |	| j&        | j'        | j(        | j)        | j*        | j+        d          | j        d<   n1| j        s*| ,                    |           | -                    |           d| _.        || j        d<   d| j        v r\| j        sU| j        d         }|j/        d         | j        d<   |j0        d         | j        d<   |j1        | j        d<   |j2        | j        d<   | j3        D ]}|4                                 | j5        r| 6                                 | 7                    |           | j        d         S )Nz7multi_y and subcoordinate_y are not supported together.c                     | j         S r   r  r   s    r   r   z-OverlayPlot.initialize_plot.<locals>.<lambda>0  s    qw r   c                     t          | t                    o2| j                            d          j                            dd          S )Nr   r'  F)r   r*   r  r  r  r0  s    r   r   z-OverlayPlot.initialize_plot.<locals>.<lambda>1  s8    :b'22orw{{67J7J7Q7U7UVgin7o7o r   c              3      K   | ]}| V  d S r   r   )r   r=  s     r   r@  z.OverlayPlot.initialize_plot.<locals>.<genexpr>3  s$      11u9111111r   zEEvery element wrapped in a subcoordinate_y overlay must have a label.rA   zKElements wrapped in a subcoordinate_y overlay must all have a unique label.c                      g | ]\  }}|||fS r   r   )r   r  r1  s      r   r   z/OverlayPlot.initialize_plot.<locals>.<listcomp>>  s%    FFF22FQGFFFr   z+All Overlays empty, cannot initialize plot.r;  c              3   @   K   | ]}t          |t                    V  d S r   )r   rK   )r   r  s     r   r@  z.OverlayPlot.initialize_plot.<locals>.<genexpr>D  s,      $`$`2ZI%>%>$`$`$`$`$`$`r   r  r   F)r   )childry   fixed)tabsrw   rx   r  r  r  r  r  Tr  r   r  r  r  r  )8r  r'  r]  r   r   r   r   r   r   r+   r  r  r  r	  r-   r  r  rk  r  r   r  r  r   r(  r[  r  r  r   r&   r  r@  r  r  rV   r   r   r  r   rw   rx   r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  )r   rF  r   r  rO  r  nonemptydkeyr   panelsr#  r  r  ry   r   s                  r   r  zOverlayPlot.initialize_plot,  s[   < 	XD0 	XVWWW 	Y^,,->->ooA  F 11&11111     3v;;1$$ &   odi011FF)=)=)?)?FFF 	O MNNN g$$TYV<<I`$`$`I]I]I_I_$`$`$`!`!`	<	<$,<??3e?LLD''---#V 	1 	1c4111000 M//11 	' 	'LCEy )#( ++FD%@@E'#344 +C..(-%&*#| -',V$y B--ce-DD F)#udinEEEhU%@@@AAAg&&&&9 		)#'4:dk.T_.T_#	$ $ $DL    	)  )))""4(((
 %WT\!!$)!<'D$(JqMDL!$(JqMDL!&*lDL#&*lDL#. 	 	BMMOOOO> 	OOG$$$|F##r   c                    |                                   t          | j        t                    o| j        }| j        | _        |s||                     |          }n||| _        || _        |g n%t          |j
                                                  }t          | j        t                    r|}n| j        }||                     |||          }|                     |d          j        |                     |d| j        d          } j        di fd|                                D               | j        j        di  | j        s$| j        s| j        s|                     ||           d | j        D             | j                                        D ]\  }}	d}
t          | j        t                    rr|rp| j        r|}
n:|8|                     ||	||          \  }}}||r|                    |          \  }}
r*t5          fd|	j        D                       r
|	| j        vr|	                    |||
           | j        sut          | j        t                    r[|rYd	| j        d	         i}| j        s| j        d         |d<    | j        |||fi | | j        s| j        s|                     |           |rc| j        s\| j        sU| j        sN| j        d         }|                      |||           | !                    |           | "                    |           d
| _#        |                     |           | $                    |           dS )z
        Update the internal state of the Plot to represent the given
        key tuple (where integers represent frames). Returns this
        state.
        Nr   Fr  c                 0    i | ]\  }}|v	||d          S )r   r   )r   r  r  r  s      r   r_  z,OverlayPlot.update_frame.<locals>.<dictcomp>  s.    \\\DAqR[I[I[1Q4I[I[I[r   c                      g | ]}|j         	|S r   r  r  s     r   r   z,OverlayPlot.update_frame.<locals>.<listcomp>  s     NNN6;MNfNNNr   c              3       K   | ]}|vV  	d S r   r   )r   r   
triggerings     r   r@  z+OverlayPlot.update_frame.<locals>.<genexpr>  s(      &T&Tqq
':&T&T&T&T&T&Tr   )r   r  Tr   )%r  r   r   r)   r(  r@  r  r  r  r   r  r	  r  rh  ri  r  _propagate_optionsr  r  r  r   r  r   rk  _match_subplotrY  r>  dynamic_subplotsr  r   _create_dynamic_subplotsr  r[  r  r  r   r  )r   r  rF  r   r  r	  r  	inheritedr  r#  r1  rP  r  exactr  init_kwargsr   r  r  s                    @@r   r  zOverlayPlot.update_frame  s    	DIz22Dt}- 	#'/ooc**GG !(D"Do40B0B0D0D+E+Edi,, 	"II	I((C@@F ++GV<<DI..w/3/F8= / ? ?I I]]\\\\IOO4E4E\\\]]]DJ**	***= 5 54< 5##GV444 ON4<NNN
---// 	: 	:JAwB $)Z00 W < / BB('+':':1gug'V'V$Cu5 %		#2  3&T&T&T&TGO&T&T&T#T#T 4#888  fb 9999| 	.
49j A A 	.e 	."DL$9:K9 ;&*l6&:F#)D)#ufLLLLL= . .$$W--- 	-4= 	- 	-4< 	-<'Dc4111""4(((&&t,,,W%%%G$$$$$r   r   r  r4  )rj  r  r  r  r  r  rD   rE   rI   re  r  r  r   r  r^  r_  r  r   r  r  r  r[  r  r  r	  r
  s   @r   r&  r&  6
  s       5= -? @ @ @D $&L&LO&L&L&LL!"%<>U$VWJ %u}U 9K L L L1 1 1* * * * *
 " " X" " " X"p; p; p; p; p;f   @1 1 1*; ; ;" " "/ / / / /R$ R$ R$ R$hJ% J% J% J% J% J% J% J%r   r&  )r  	itertoolsr   typesr   r   bokeh.plottingnumpyrd  r  bokeh.document.eventsr   bokeh.modelsr   r   r   r	   r
   r   r   r   r   r   bokeh.models.axesr   r   bokeh.models.formattersr   r   r   bokeh.models.layoutsr   r   bokeh.models.mappersr   r   r   bokeh.models.rangesr   r   r   bokeh.models.scalesr   bokeh.models.tickersr   r   r    r!   r"   bokeh.models.toolsr#   packaging.versionr$   corer&   r'   r(   r)   r*   r+   core.optionsr,   r-   r.   r   r/   r0   r1   r2   r3   r4   r   r5   r6   r7   util.transformr9   r   r;   r<   r=   r>   r?   r@   rB   stylesrC   rD   rE   rF   rG   rH   rI   rJ   tabularrK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   _known_aliasesr   	Exceptionrc   r  r#  r  r  r&  r   r   r   <module>r     s                          3 3 3 3 3 3                        < ; ; ; ; ; ; ;         
 0 / / / / / / /         
 B A A A A A A A A A ( ( ( ( ( (              $ # # # # # % % % % % % S S S S S S S S S S S S S S S S J J J J J J J J J J L L L L L L L L L L L L L L L L 0 0 0 0 0 0 0 0 0 0 ! ! ! ! ! ! 9 9 9 9 9 9 9 9 O O O O O O O O O O O O      	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	                                                     2#II   IIIw0 w0 w0 w0 w0)/ w0 w0 w0t=r( r( r( r( r(; r( r( r(lW W W W W; W W Wt
B4 B4 B4 B4 B4 B4 B4 B4L       T% T% T% T% T%$j T% T% T% T% T%s   ,D4 4D>=D>