a
    ~b                    @   sh  d dl mZmZmZ d dlZ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 d dl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#m$Z$ d dl%m&Z&m'Z'm(Z( d dl)m*Z*m+Z+m,Z,m-Z-m.Z. d dl/m0Z0 d dl1m2Z2m3Z3 ddl4m5Z5m6Z6m7Z7m8Z8m9Z9 ddl:m;Z;m<Z< ddl4m=Z= ddl>m?Z?m@Z@mAZAmBZBmCZCmDZD ddlEmFZFmGZGmHZH ddlImJZJ ddlKmLZLmMZM ddl=mNZNmOZOmPZP ddlQmRZR ddlKmSZS ddlTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\ ddl]m^Z^ ddl=m_Z_m`Z`maZambZbmcZcmdZdmeZemfZfmgZgmhZhmiZimjZjmkZkmlZlmmZmmnZnmoZompZp zd dlmqZq W n eryx   dZqY n0 zd d lmsZs W n ery   dZsY n0 eae_d!krz
e0jtZuW n evy   e`ZuY n0 n(eae_d"krd d#lwmuZu nd d$lxmyZu G d%d& d&eSeLZzG d'd( d(ezZ{G d)d* d*ezZ|G d+d, d,ezZ}G d-d. d.e~ZG d/d0 d0eMe}ZdS )1    )absolute_importdivisionunicode_literalsN)chain)FunctionType)value)ModelChangedEvent)ColorBarColorMapperLegendRendererTitletools)CategoricalAxisDatetimeAxis)FuncTickFormatterTickFormatterMercatorTickFormatter)LinearColorMapperLogColorMapperCategoricalColorMapper)Range1dDataRange1dFactorRange)TickerBasicTickerFixedTicker	LogTickerMercatorTicker)Tool)PanelTabs   )
DynamicMapCompositeOverlayElement	DimensionDataset)abbreviated_exceptionSkipRendering)util)
AnnotationContoursGraphPathTilesVectorField)BufferRangeXYPlotSize)dim   )GenericElementPlotGenericOverlayPlot)process_cmapcolor_intervalsdim_range_key   )PlotSizeCallback)	BokehPlot)base_propertieslegend_dimensionsline_propertiesmpl_to_bokehproperty_prefixes
rgba_tupletext_propertiesvalidate)	TablePlot)LooseVersion
TOOL_TYPESbokeh_versiondate_to_integerdecode_bytesget_tab_titleglyph_orderpy2js_tickformatterrecursive_model_updatetheme_attr_jsoncds_column_replacehold_policymatch_dim_specscompute_layout_propertieswrap_formattermatch_ax_typeprop_is_noneremove_legend)EqHistColorMapper)BinnedTickerz2.0.1z2.0.0)	TOOLS_MAP)_known_toolsc                       sJ  e Zd Zejg ddZejdg 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ddZejdddddZejd	ddddZejd	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dZej
d	ddZejdg ddZej
ddidddZeji ddZejddgd dZejddd!d"d#d$dZejdd%dZejdd&dZejg d'd(dZ ejg d)dZ!ejd*g d+d,dZ"ej#d	e$j%e&e'fd-d.Z(ej#d	e$j%e&e'fd-d.Z)dZ*dZ+g Z,e-Z.e-Z/dZ0d fd/d0	Z1d1d2 Z2g fd3d4Z3d5d6 Z4dd7d8Z5d9d: Z6d;d< Z7d=d> Z8dd?d@Z9dAdB Z:dCdD Z;dEdF Z<dGdH Z=dIdJ Z>d	dKdLdMfdNdOZ?ddPdQZ@dRdS ZAdTdU ZBdVdW ZCdXdY ZDddZd[ZEd\d] ZFd^d_ ZGd`da ZHdbdc ZIddde ZJdfdg ZKddhdiZLddjdkZMdldm ZNdndo ZOdpdq ZPdrds ZQddtduZRdvdw ZSdxdy ZTddzd{ZUd|d} ZVeWd~d ZX  ZYS )ElementPlotz
        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.defaultdocstart)ra   centerendzD
        Alignment (vertical or horizontal) of the plot in a layout.r_   objectsr`   
   z$
        Minimum border around plot.Na(  
        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.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.)r_   
allow_Noneboundsr`   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.)r_   ri   r`   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).F)FTwidthheight)r_   re   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'})r_   rh   r`   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.xyz0
        Whether to plot the 'x' and 'y' labels.i    )ZfactorintervalZ	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.)ZsaveZ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leftrv   disableNz^
        The toolbar location, must be one of 'above', 'below',
        'left', 'right', None.z.
        Formatter for ticks along the x-axis.r_   class_r`   c                    s   d | _ tt| j|fi | |d u r*i n| jd | _t| jdkoVt| jt| jk| _| 	 \| _
| _d| _dd | jD | _t| jjdd t| _| jr| jd u rd| _ddd	| _d| _d S )
Nplotr;   Fc                 S   s   g | ]}t |tr|qS  )
isinstancer1   .0sr~   r~   ?lib/python3.9/site-packages/holoviews/plotting/bokeh/element.py
<listcomp>       z(ElementPlot.__init__.<locals>.<listcomp>c                 S   s   | S Nr~   rn   r~   r~   r   <lambda>   r   z&ElementPlot.__init__.<locals>.<lambda>mercatorrn   ro   )current_rangessuperr]   __init__handleslenhmapkeysstaticZ_construct_callbacks	callbacksZsource_streamsstatic_sourcestreams	streamingboollasttraverser/   
geographic
projection_shared_updated)selfelementr}   params	__class__r~   r   r      s    $zElementPlot.__init__c                 C   sB   | j rt| jjj}nt| j }|| 7 }tt	|i fS r   )
batchedlistr   r   kdimsoverlay_dimsr   
dimensionsr*   unique_iteratorr   r   dimsr~   r~   r   _hover_opts   s
    zElementPlot._hover_optsc                    s
  |  |\ dd D s$d|| j }g g  }d}|D ]p}|j|j D ]^}|rP|tv rP| |dkrtjf dgd }|}n
t|  }|| || j|< qPq@fdd|| j	 | j D } fd	d|D }g }	|D ]:}t
|tjr|jdd
}
t|f i |
}|	| qdd |	D }d|	v rhtjf dgd }||	|	d< nt|rz|d }|r|| jd< dd |	D }|r|d | jd< dd |	D }|r|d | jd< |r|r|d d|d d |d d|d d |	S )I
        Processes the list of tools to be supplied to the plot.
        c                 S   s0   g | ](}t |tr(|jd t|j fn|qS @{%s}r   r&   Zpprint_labelr*   dimension_sanitizernamer   Zttpr~   r~   r   r      s   
z+ElementPlot._init_tools.<locals>.<listcomp>NFhover
hv_created)tooltipstagsc                    s   g | ]}| vr|qS r~   r~   r   t)
tool_namesr~   r   r     s   c                    s2   g | ]*}|d v r*t jf dg|d n|qS ))ZvlineZhliner   )r   r   mode)r   	HoverTool)r   tl)
hover_optsr   r~   r   r     s   Zinclude_defaultsc                 S   s   g | ]}t |tjr|qS r~   r   r   r   r   r~   r~   r   r     r   r   c                 S   s   g | ]}t |tjr|qS r~   )r   r   ZBoxSelectToolr   r~   r~   r   r   '  r   Z
box_selectc                 S   s   g | ]}t |tjr|qS r~   )r   r   ZLassoSelectToolr   r~   r~   r   r   *  r   Zlasso_selectr   )r   r   modelsZextra_modelsr[   appendr   r   r   default_toolsr   r   properties_with_valuestypeindexanyZjs_link)r   r   r   Zcb_toolsr   cbZhandletoolZ	tool_listZcopied_tools
propertieshover_toolsZ	box_toolsZlasso_toolsr~   )r   r   r   r   _init_tools   sh    








zElementPlot._init_toolsc                 C   sr   | j d }d|jv r8| |\}}dd |D }||_n6|jdd}dd |jdg D }|rn|d	 j|_d S )
Nr   r   c                 S   s0   g | ](}t |tr(|jd t|j fn|qS r   r   r   r~   r~   r   r   9  s   
z-ElementPlot._update_hover.<locals>.<listcomp>r}   bokehc                 S   s   g | ]}t |tjr|qS r~   r   r   r~   r~   r   r   >  s   r   r   )r   r   r   r   optsgetkwargs)r   r   r   r   r   	plot_optsZ	new_hoverr~   r~   r   _update_hover5  s    

zElementPlot._update_hoverc                    s   d| j vs| jrdS |p| D ]&}t|j}||vr ||||< q | j D ]F\} t|j}||vrR fddt	t
t| d D ||< qRdS )zv
        Initializes hover data based on Element dimension values.
        If empty initializes with no data.
        r   Nc                    s   g | ]} qS r~   r~   )r   _vr~   r   r   S  r   z/ElementPlot._get_hover_data.<locals>.<listcomp>r   )r   r   r   r*   r   r   dimension_valuesr   itemsranger   r   values)r   datar   r   dr4   kr~   r   r   _get_hover_dataC  s    zElementPlot._get_hover_datac                 C   s   i }|D ]}|du rqt |dr|jjr|durt|jjd |rXt|j|rX|j|d< t|jjd |rt|j|r|j|d< t |dr|jjr|durt|jjd |rt|j|r|j|d< t|jjd |rt|j|r|j|d< q|S )z
        Given a list of other plots return axes that are shared
        with another plot by matching the dimensions specs stored
        as tags on the dimensions.
        Nx_ranger   y_range)hasattrr   r   rS   rV   xaxisr   yaxis)r   plotsxspecsyspecsxtypeytypeplot_rangesr}   r~   r~   r   _merge_rangesV  s    


zElementPlot._merge_rangesc                 C   s6   |  dd }t|dkr(|ddg S |dg S dS )zReturns the dimensions corresponding to each axis.

        Should return a list of dimensions or list of lists of
        dimensions, which will be formatted to label the axis
        and to link axes.
        Nr5   r;   )r   r   r   r~   r~   r   _get_axis_dimsm  s    zElementPlot._get_axis_dimsc           !         sZ  | dd dd g}|r"|d n|}t|tr6|j}| |}| |\}}}	| jrv|| }}|d d d d d }|d d \}
}|
rt|
ts|
g}
tdd |
D }nd }|rt|ts|g}td	d |D }nd }| j	rt| t
s|n|}| | \}}}}| jr&||||f\}}}}t|  d
d }|
d ur`t fdd|
D r`d}ntdd ||fD }|d urt fdd|D rd}ntdd ||fD }| j| jf}| jr|d d d }|\}}| jrdnd}|
rRt|
dks|tu rd}d}n<||
d }|tju rBtt|tjsN|tjv rRd}| jr^dnd}|rt|dks|tu rd}d}nZt|tr|j|d }n||d }|tju rtt|tjs|tjv rd}i }| |dj}|r$| jr$|dds$| |||||}|d|d }} |r`|tu rVt|tr`d| jd< | r|tu r|t| trd| jd< | jd rn&|s|rd}t |d< n
| |d< | jd rn0|s|rd}t |d< nd|vr| |d< |d |d  }} |j s(|d ur(|j !| | j sF|d urF| j !| ||f|||	f|fS )Nc                 S   s   | S r   r~   r   r~   r~   r   r   }  r   z)ElementPlot._axes_props.<locals>.<lambda>c                 S   s   t | tot | ttf S r   )r   r%   r+   r/   )elr~   r~   r   r   }  r   r   r5   c                 s   s   | ]}|j |j|jfV  qd S r   r   labelZunit)r   Zxdr~   r~   r   	<genexpr>  r   z*ElementPlot._axes_props.<locals>.<genexpr>c                 s   s   | ]}|j |j|jfV  qd S r   r   )r   Zydr~   r~   r   r     r   c                 S   s   | j S r   )_categoricalr   r~   r~   r   r     r   c                 3   s&   | ]}|j  v od  |j  v V  qdS factorsNr   )r   xdimrangesr~   r   r     r   Tc                 s   s   | ]}t |tjtfV  qd S r   r   r*   
basestringbytes)r   rn   r~   r~   r   r     r   c                 3   s&   | ]}|j  v od  |j  v V  qdS r   r   )r   ydimr   r~   r   r     r   c                 s   s   | ]}t |tjtfV  qd S r   r   )r   ro   r~   r~   r   r     r   logautor;   datetimenormZaxiswiseFr   r   rn   ro   )"r   r   r-   nodesr   _get_axis_labelsinvert_axesr   tupler   OverlayPlotget_extentsr   _x_range_type_y_range_typelogxr   r   Zget_dimension_typenpZobject_
issubclassr   r*   datetime_typeslogylookup_optionsoptionsshared_axesr   r   r   r   r   )!r   r   subplotsr   r   r   r   xlabelylabelzlabelZxdimsZydimsr   r   Zrange_ellbrr   categoricalZcategorical_xZcategorical_yZrange_typesZx_range_typeZy_range_typex_axis_typer   y_axis_typer   r   Z	norm_optsr   r   r~   r   r   _axes_props{  s    




""




zElementPlot._axes_propsc                 C   sf  | j rt| j  ng }| ||||\}}}|\}	}
}|\}}t|}d| jv sX| jr\|	nd|d< d| jv st| jrx|
nd|d< | jsd|d< | j	r| j
du r| j|dd	}nd
}| jdkr| |}||d< | j|d< ng |d< d|d< | jjrd|d< |jf i | || t 6 tdt tjjf |||d|W  d   S 1 sX0    Y  d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.
        rn    Zx_axis_labelro   Zy_axis_labelr   Zoutline_line_alphaN	separator rz   r   Ztoolbar_locationwebglZoutput_backendignore)r  r  rl   )r  r   r   r  dictlabelledr  r  
show_frame
show_titleadjoined_format_titletoolbarr   rendererr  update_plot_propertieswarningscatch_warningssimplefilterUserWarningr   ZplottingZFigure)r   keyr   r   r   r  Z
axis_typeslabelsr   r  r  r   r  r  r   rl   r   r~   r~   r   
_init_plot  s8    




zElementPlot._init_plotc                 C   s  d| j v}| jjd }| j|dddgdd}|r6| jnd}t| j| j| j| j	|
d|
d| j| j| j||d\}}|s|d	 du r| jj|d	< | jr|d
 rdd | jD }	dd | jD }
|	r|	d }n0|
r|
d jd }nt }| jt| |gd || j | j| j| j| j| j| jd}|| | jsH|| | j rZ| j |d< | j!durdD ]}| j!|d| < qjt"| j# 
di fi | j$}|% D ]\}}||d| < q|S )z:
        Returns a dictionary of plot properties.
        r}   g      Y@rj   rk   FdefaultsN)loggeraspect_ratiomatch_aspectc                 S   s   g | ]}t |tr|qS r~   r   r3   r   r~   r~   r   r   *  r   z0ElementPlot._plot_properties.<locals>.<listcomp>c                 S   s   g | ]}t |tr|qS r~   )r   r<   r   cr~   r~   r   r   +  r   r   )alignmargin	max_width
max_height	min_width
min_heightbackground_fill_color)ry   rv   topbottomZmin_border_lodZlod_)&r   r&  size_traverse_optionsparamrT   rj   rk   frame_widthframe_heightr   aspectdata_aspect
responsivestater3  dynamicr   r   r3   r   r<   Zadd_subscriber_update_sizer8  r9  r:  r;  r<  r=  r'  drawnbgcolorborderr  r1  rA  r   )r   r-  r   initZsize_multiplierr  r2  Zaspect_propsZdimension_propsZ	plot_sizer   streamZ
plot_propsprA  Zlod_propr   r~   r~   r   r(    sR    





 zElementPlot._plot_propertiesc                 C   s$   | j jdkrd S || j_|| j_d S )Nserver)r&  r   rJ  rE  rF  )r   rj   rk   Zscaler~   r~   r   rL  K  s    zElementPlot._update_sizec                    s   | j D ]}t|tjrRt|   fdd|jjD }|sJ| jd|  q|d }t|tj	rf||j_
t|tjrz||j_t|tjr||j_t|tjr|jj| qdS )z"Activates the list of active toolsc                    s   g | ]}t | r|qS r~   )r   r   	tool_typer~   r   r   V  s   
z1ElementPlot._set_active_tools.<locals>.<listcomp>zITool of type %r could not be found and could not be activated by default.r   N)active_toolsr   r*   r   rH   r%  r   rD  warningZDragZactive_dragZScrollZactive_scrollZTapZ
active_tapZ
InspectionZactive_inspectr   )r   r}   r   Zmatchingr~   rT  r   _set_active_toolsQ  s$    
zElementPlot._set_active_toolsc                 C   sj   | j r | jd u r | j|dd}nd}t|d}| dd}|dkrfttdkrV|nt|}||d	< |S )
Nr  r  r  )textrl   fontsizerm   2.2.3Ztext_font_size)	r"  r#  r$  r  	_fontsizer   rI   rG   r   )r   r-  r}   r   rl   r   Z
title_fontr~   r~   r   _title_propertiesh  s    
zElementPlot._title_propertiesc                 C   s   | j d u rd|j _n6t| j tjrJd| j v rJ|j|_g |_|j|j d d < |j d | jd< |j| jd< | j	d u rzd|j	_n6t| j	tjrd| j	v r|j
|_g |_
|j|j	d d < |j	d | jd< |j| jd< d S )	NFr?  r   r   r   rv   r   r   )r   visibler   r*   r   rx   rw   r   r   r   ry   rv   r   )r   r}   r~   r~   r   
_init_axesw  s     



zElementPlot._init_axesr   r;   r   c                 C   s  t t| jjd}|dkr$| jdv s6|dkrr| jdv rrttdkrFdntd}||d< ||d	< d
|d< d
|d< n| 	d| 
d}|r||d< | j	d| dd
d}	|	rttdkr|	nt|	}	|	|d	< |dkr| jn| j}
|
rt|
|d< |dkr| jn| j}t|tjr t|}t|tr6||d< nt|trRt|d|d< nt|ttfrtdd |D rt| \}}dd |D }dd |D }n
|d
 }}|rt|d rdd |D }t|d|d< |d
urt t|||d< |dkr| jn| j}|r2t||}|d
ur||d< n|t d
ur|rt|t!rd
}|j"rb|j"}n|j#|j$v r||j$|j# }|rd|j% }t&||}|rt |d }||d< |dkr|jd }n|dkr|jd }| j'rjt| j(t)rj| j(d!krj|dkrd"nd#}t*|d$|d< t+|d$|d< | j,j-t.j/d%}|rHd&|d _0| j,j-t.j1d%}|rd|d _2nlt|t3rt|D ]*}|4d'r~|5d'd(}|| ||< q~| j	d)6|dd
d}|d
ur||d	< |S )*zb
        Returns a dictionary of axis properties depending
        on the specified axis.
        ZAxisrn   )zbottom-bareztop-barebarero   )z	left-barez
right-barer`  r[  Z0ptZaxis_label_text_font_sizemajor_label_text_font_sizeNmajor_tick_line_colorZminor_tick_line_colorz%slabelrZ  z%sticksFcommonZmajor_label_orientationticker)Zdesired_num_ticksc                 s   s   | ]}t |tV  qd S r   )r   r  r   r~   r~   r   r     r   z/ElementPlot._axis_properties.<locals>.<genexpr>c                 S   s*   g | ]"}t |tr"| r"t|n|qS r~   )r   float
is_integerintr   r~   r~   r   r     s   z0ElementPlot._axis_properties.<locals>.<listcomp>c                 S   s$   g | ]}t |tjr|nt|qS r~   )r   r*   r   str)r   r  r~   r~   r   r     s   r   c                 S   s   g | ]}t |d qS )ms)r*   Z	dt_to_int)r   Ztickr~   r~   r   r     r   )ticksZmajor_label_overrides	formatterzA%s dimension formatter could not be converted to tick formatter. )coder   ZlonZlat)	dimensionr   TZmajor_labelgroupzminor_{0}ticks)7r  rP   r&  Zthemer   r   rI   rG   r   r\  r   	xrotation	yrotationr  Zradiansxticksyticksr   ndarrayr   r   rh  r   r  allzipr*   Z
isdatetimer   
xformatter
yformatterrU   r   r&   Zvalue_formatr   Ztype_formattersr   rN   r   r   ri  r   r   rJ  selectr   BoxZoomToolr4  WheelZoomToolzoom_on_axisr   
startswithreplaceformat)r   axisr-  r}   rn  Z
ax_mappingZ
axis_propsZzero_pt	labelsizeticksizeZrotationre  rk  r.  rl  msgZjsfuncZaxis_objrt   rs   Znew_keyZmsizer~   r~   r   _axis_properties  s    












zElementPlot._axis_propertiesc                 C   sB   |j f i | || | ||| | ||| | | dS )z8
        Updates plot parameters on every frame
        N)r'  r(  _update_labels_update_title_update_gridr   r-  r}   r   r~   r~   r   _update_plot  s    zElementPlot._update_plotc           
         s   | dd tg}|r|d n|}|} fddtddg|D }|\}}}	jrl|| }}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   s   | S r   r~   r   r~   r~   r   r     r   z,ElementPlot._update_labels.<locals>.<lambda>r   c              	      s"   i | ]\}}| | |qS r~   )r  )r   r  r4   r-  r}   r   r~   r   
<dictcomp>   s   z.ElementPlot._update_labels.<locals>.<dictcomp>rn   ro   r  Z
axis_label)r   r%   r   rw  r   r   r   r  r  rO   r   r   r   )
r   r-  r}   r   r   r   propsr  r  r  r~   r  r   r    s    

  zElementPlot._update_labelsc                 C   sB   |j r$|j jf i | ||| ntf i | ||||_ d S r   )rl   r'  r]  r   r  r~   r~   r   r    s    zElementPlot._update_titlec                    s
  | j sd |j_d |j_d S g d t| j }dd |D }dd |D }dd |D } fddt|fi | D } fddt|fi | D }|jrd|vr|jd	 j	|d< |j
rd|vr|j
d	 j	|d< |jd	 jf i | |jd	 jf i | d S )
N)ri   Zbandsr^  levelre  r^  c                 S   s*   i | ]"\}}| d s | dr||qS )grid_Z
minor_grid)r~  r   r   r   r~   r~   r   r    r   z,ElementPlot._update_grid.<locals>.<dictcomp>c                 S   s&   i | ]\}}d |v r| d d|qS )xgridgridr  r  r~   r~   r   r    r   c                 S   s&   i | ]\}}d |v r| d d|qS )ygridr  r  r  r~   r~   r   r    r   c                    s8   i | ]0\ }t  fd dD r. ddn |qS )c                 3   s   | ]}| v V  qd S r   r~   r   r  r   r~   r   r     r   6ElementPlot._update_grid.<locals>.<dictcomp>.<genexpr>r  r  r   r  r   r   r  r  r   r    s   c                    s8   i | ]0\ }t  fd dD r. ddn |qS )c                 3   s   | ]}| v V  qd S r   r~   r  r  r~   r   r     r   r  r  r  r  r  r  r  r   r    s   re  r   )	show_gridr  Zgrid_line_colorr  r   	gridstyler   r  r   re  r   r'  )r   r}   Zstyle_itemsZbothr  r  ZxoptsZyoptsr~   r  r   r    s*    

zElementPlot._update_gridc           0   
   C   s  | j d }| j d }| j d }d\}}}}	tdd ||fD rn| ||\}}}}	| jrn|||	|f\}}}}	d\}
}tdd ||fD r| ||\}
}| j}| jotd	d | jD }| |p| | r|p|p|
d u}| |p| | o|p|p|d u}| j|dd
dgdd}| j	p0|
d
}| jpB|
d}|
dpX|
d}|
dpn|
d}| jdkp| j}| j d | j d  }}t|tpt|t}t|tpt|t}|r|s|r|rdnd}| jd|  nJ|rB| j d }t|r(t|r(|| nd }t|rLt|	rL|	| nd }| jsp|rd|sp|sp|r\| jpzd}| jdkrd}n>| jr| jdkr| j}n"|jr|j	r|j|j	 }nd S dd | jD }| jr|jj|jj } }!|jj|jj }"}#|!|  |#|"  }$}%n||||	f\} }!}"}#|| }$}%tdd |D rl| |!|"|#f\}}}}	|$|% }}dd | jD }&tdd |&D r| jrd S |||  }'|||  }(tj|'|dd rtj|(|dd sZt|rZt|snh|(|kr,|$||  }(|(| d! })||) |	|)  }}	d"}n.|%||  }'|'| d! }*||* ||*  }}d"}n|rh|s| ||}+|j	p|j pd#},|jp|j!pd#}-|s|s| j"sd"}|r|-|_t#|-|+ |_	d\|_ |_!n2|r|,|_	t#|,|+ |_d\|_ |_!n
d$|+ |_$|j%t&j'd%}.|j%t&j(d%}/|.r6d"|._)|/rBd|/_*| jrP|rr| +||||
| j,| j-d& | j.| | jr|r| +|||	|| j/| j-d' | j0| d S )(Nr}   r   r   )NNNNc                 s   s   | ]}t |ttfV  qd S r   )r   r   r   r  r~   r~   r   r   .  r   z-ElementPlot._update_ranges.<locals>.<genexpr>NNc                 s   s   | ]}t |tV  qd S r   )r   r   )r   Zax_ranger~   r~   r   r   4  r   c                 s   s   | ]}|j o|jV  qd S r   )_triggeringZ	followingr   rQ  r~   r~   r   r   7  s   rj   rk   Fr0  r<  r:  r=  r;  equalr   r   r  zdatetime axeszNCannot set data_aspect if one or both axes are %s, the option will be ignored.r;   squarec                 S   s   g | ]}t |tr|qS r~   )r   r2   r   r~   r~   r   r   c  r   z.ElementPlot._update_ranges.<locals>.<listcomp>c                 s   s   | ]}|j V  qd S r   r  )r   Zrsr~   r~   r   r   l  r   c                 S   s   g | ]}t |tr|qS r~   r5  r   r~   r~   r   r   t  r   c                 s   s   | ]}|j V  qd S r   r  )r   ssr~   r~   r   r   u  r   g?)Zrtolg       @Trg   g      ?ro  rn   ro   )1r   r   r  r   _get_factors	framewiser   model_changedrC  rE  r   rF  rG  rH  r   r   r   rD  rW  r*   	is_numberrM  r   r   ra   rc   r   r   r  Zallcloseisfinite
get_aspectZ
plot_widthZplot_heightrI  rh  r3  rz  r   r{  r|  r4  r}  _update_rangeinvert_xaxisr   r  invert_yaxisr
  )0r   r   r   r}   r   r   r  r  r  r   xfactorsyfactorsr  r   ZxupdateZyupdater  Zfixed_widthZfixed_heightZconstrained_widthZconstrained_heightrH  r   r   r  r   Zax_typexspanyspanZratioZframe_aspectZrange_streamsZ	current_lZ	current_rZ	current_bZ	current_tZcurrent_xspanZcurrent_yspanZsize_streamsZdesired_xspanZdesired_yspanZypadZxpadrG  rj   rk   rt   Zscroll_zoomr~   r~   r   _update_ranges(  s    




$$ 



zElementPlot._update_rangesc	                 C   s  t |ttfr| jrt |tjr&nt||kr|d urt |tjrvtdd}	t	|t	| }}||	8 }||	7 }n$t
|r|d nd}	||	8 }||	7 }|r|j|jf}t||f|g\}}|r|| }}t |tjs$|r$|d u s|dkr$|dk rdndt|d  }| jd	|  i }
t|rN|j|f|
d
< |
d
 |
d< t|rt|j|f|
d< |
d |
d< |
 D ]X\}\}}t |tjrt|}|jf i ||i |r||ds||||| q|n2t |tr
tt|}|r|d d d }||_d S )Nrp   rj  g?g      ?r   g{Gz?rf   r5   zLogarithmic axis range encountered value less than or equal to zero, please supply explicit lower-bound to override default of %.3f.ra   Zreset_startrc   Z	reset_endZreset_r   )r   r   r   Zapply_rangesr*   Zcftime_typesr	  r  Ztimedelta64Z
datetime64absra   rc   Z	max_rangeZlog10rD  rW  r  r   rJ   r'  r~  Ztriggerr   r   rK   r   )r   Z
axis_rangelowhighr   invertZsharedr   r   offsetZupdatesr   oldnewr~   r~   r   r    sP    
& zElementPlot._update_rangec                    s   j r*|ddd } dd ddd  fdddD }t|D ]L\}|| }t| trDt|tsx|jjdvrD fdd|D ||< qDd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   r5   c                    s   g | ]} j d |  qS )z%s_range)r   )r   axr   r~   r   r     r   z0ElementPlot._categorize_data.<locals>.<listcomp>ZxySUc                    s   g | ]}   |qS r~   pprint_valuer  )r   ir~   r   r     r   )r   	enumerater   r   r   dtypekind)r   r   Zcolsr   r   colcolumnr~   )r   r  r   r   _categorize_data  s    
zElementPlot._categorize_datac                 C   s   d| j v r*| jjr*| jjr*| jj| jj S | jr>|| | j S | jdkrP|| S | jdkr^dS | jdurn| jS | jdur| jdur| j| j S dS dS )z7
        Computes the aspect ratio of the plot
        r}   r  r  r;   N)r   rJ  rE  rF  rH  rG  rj   rk   )r   r  r  r~   r~   r   r    s    


zElementPlot.get_aspectc                 C   s  |  dd \}}|jr"|j}n.d||ji v rD||j d }n|dd}|jr^|j}n.d||ji v r||j d }n|dd}t|t| }}| js|jj	dv r|ng }|jj	dv r|ng }t
dd	 ||f||ffD }| jr|ddd
 }|S )z3
        Get factors for categorical axes.
        Nr5   r   r   Fr;   r  c                 3   s&   | ]\  fd dD V  qdS )c                    s&   g | ]}j jd v r|n |qS )r  )r  r  r  r  r4   Zvalsr~   r   r     r   z6ElementPlot._get_factors.<locals>.<genexpr>.<listcomp>Nr~   )r   r~   r  r   r     s   z+ElementPlot._get_factors.<locals>.<genexpr>r   )r   r   r   r   r   r  Zasarray_allow_implicit_categoriesr  r  r  r   )r   r   r   r   r   ZxvalsZyvalsZcoordsr~   r~   r   r    s(    zElementPlot._get_factorsc                 C   s0   | j d jD ]}g |jdd< d|_d|_qdS )z>
        Disables legends if show_legend is disabled.
        r}   Nr   )r   legendr   Zborder_line_alphabackground_fill_alpha)r   r  r~   r~   r   _process_legend  s    zElementPlot._process_legendc                 C   sv   t |}| j| jrdnd}t|tr6|t| j }d|v rLd|v rL|d= t||f i t	|fi |}||j
fS )/
        Returns a Bokeh glyph object.
        r   Zsinglelegend_fieldlegend_label)rA   Z_plot_methodsr   r   r   r  rh  r   getattrr  glyph)r   r}   mappingr   plot_methodr&  r~   r~   r   _init_glyph(  s    
 zElementPlot._init_glyphc                 C   s   |j ||ddS )NTr   Zflat)apply)r   	transformr   r   r~   r~   r   _element_transform7  s    zElementPlot._element_transformc                    s  t |}|r|d ndt | D ]\\}ttjrt|dkrLq$nZ|v sht|trr|jv rrtn4t	fddj
D rtfddj
D d ttr$|d ur||sq$n6|sjj
vr|| jd	|f  q$jj
v r@td
d j
 D tj
}j||ddd }	n||}	t|	stt|	dkrd|vstd|	s|jv r|	d }	t|	s:|jv rt|j}tdj|j|jjdnb|r:t|	tt| d kr:t|t rt!"|	d}	n$t|t#r$t|t$s$|	d d }	nq$|dkrPt!%|	}	n\|&drt|	rt|	t'rt(d }	n*t|	t!j)r|	j*j+dv rdd |	D }	t|	r|	}
n|dkr|nd|i}
|	||< t|	tj,o|	j*j+dv }|-d }d|v rzt|	tj,rz|s:td|	r:t|t rzi }|	j*j+dvrt.}||v rzd|| v rz|| d }n
t|	}t|	tj,r|	j*j+dkr|/t(}||d< j0||t |f|d |d |}t|t1}|r:|	j*j+d!v r:j|v r|2jj3 nt( |d" } fd#d|	D ||d" < n|}|rpt4d$d%rpt5t6d&krdd'nd(}|||< ||d)}
|
||< q$t| D ]L\}}	d*D ]:}| |ks||vst||	drΐqt	fd+dj7D }d,d t8D dg D ]}| d- | }|-|}|d.v r.|d/ks|j7vr>q|d0k}|d u sdt||drr|sr|rr|	||< | d1 | }|-|}|r|d urq|d urt||r|r|d u r|s|	||< qqq|S )2Nr   r  Tc                 3   s   | ]}| kV  qd S r   r~   r   r   r   r~   r   r   D  r   z0ElementPlot._apply_transforms.<locals>.<genexpr>c                    s   g | ]}| kr|qS r~   r~   r  r   r~   r   r   E  r   z1ElementPlot._apply_transforms.<locals>.<listcomp>r   z\Specified %s dim transform %r could not be applied, as not all dimensions could be resolved.c                 S   s   i | ]\}}|j |qS r~   r   r   r   r   r~   r~   r   r  Q  r   z1ElementPlot._apply_transforms.<locals>.<dictcomp>r  r;   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.)styler4   r   backendr"   r   ZangleZ	font_sizeptZifuc                 S   s   g | ]}t t|d  qS )r  )ri  rh  r   r~   r~   r   r   t  r   Znode_markerfieldZuifMmbcmapZifMur   r  Z_color_mapper)r   rp  ZifMub_str__c                    s   g | ]} |qS r~   r~   r  rl  r~   r   r     r   show_legendF1.3.5r  r  r  r  )alphar  c                 3   s0   | ](}|  d  o& dkp&tddV  qdS )fillZedge_ZfilledTN)r~  r  )r   o)prefixr   r~   r   r     s   c                 S   s   g | ]}|d  qS )r   r~   r   rR  r~   r~   r   r     r   fill_)nonselection_muted_r  hover_line_)9r  r   r   r*   r   rE   r-   r   r4   r   r   r~  Zappliesrn  poprD  rW  r'   r   r  r  Zisscalarr   unique_array_nonvectorized_stylesr   __name__
ValueErrorr  r&  r  r   r0   r  Ztiler.   r,   Zdeg2radendswithrh  ri  ru  r  r  Zarraylike_typesr   r:   Zastype_get_colormapperr   get_dimensionr  r  rI   rG   
style_optsrB   )r   r   r   r   r  rp  Z	new_styler   Zdsvalr-  numericZcolormapr   	range_keyr   cmapperr  r  legend_propr   Zsupports_fillZpprefixZfill_keyZ
fill_styler   Zline_keyZ
line_styler~   )rl  r  r   r   r   _apply_transforms;  s    

 

$







&

zElementPlot._apply_transformsc           
      C   sd   t ||d}| jr`| jr4ddd | j D }n|j}|r`| jr`ttdkrTdnd}	|||	< |S )N)source, c                 S   s   g | ]\}}|j |d dqS )T)Z
print_unitr  r  r~   r~   r   r     r   z1ElementPlot._glyph_properties.<locals>.<listcomp>r  r  r  )	r  r  r   joinr   r   overlaidrI   rG   )
r   r}   r   r  r   r  rp  r   r  r  r~   r~   r   _glyph_properties  s    


zElementPlot._glyph_propertiesc                    s   t |}|r|dfndD ]dD ]Z}|| }|d urVd| |vsJrV||d| < |d ur d| |vsnr ||d| < q fdd| D }| jrt |fi |}q|| q fdd| D S )	Nr  )r  )r  r  r  r  c                    s,   i | ]$\}}|  r|t d  |qS r   )r~  r   r  )gtyper~   r   r    s   
z2ElementPlot._filter_properties.<locals>.<dictcomp>c                    s   i | ]\}}| v r||qS r~   r~   r  )allowedr~   r   r    r   )r  r   r   r   r'  )r   r   
glyph_typer  Zglyph_propspropZ
glyph_propr  r~   )r  r   r   _filter_properties  s    zElementPlot._filter_propertiesc           !   
   C   sX  |  }t|}t|fi |}ttdkr0dnd}	|	D ]}
||
d }|d ur8 qVq8t|j }g }dD ]}|rt	||d d }|dkr|j
}| }t|f i dd | D }t||d | |rl|s|rql| |||}| }|D ]|}||}t	||}t|tr"|d	n|}t|tr<|d	n|}|d u s||vs||jv s||krfq|| q|||f ql|d u rd
nt||}|s| js| || t| drt| jd urt| | n| jrt| jjdk}t| jd|df dd |D }t| j|d|j||dd}ttdkrF| jjj | n| jj | W d    n1 sj0    Y  |d ur| j!j"D ]}|jD ]z}||j#v rt|tr|}nP|
dkrd|
v rdnd	}||i}n*t|j$trt|j$d |i}nd|i}||_$qq|D ]\}} |j%f i |  q|d urT|rT| jsT| || d S )Nr  )r  r  )r  )r  Z
selection_r  r  r  r  r   c                 S   s   i | ]\}}t |s||qS r~   )rW   r  r~   r~   r   r    s   z-ElementPlot._update_glyph.<locals>.<dictcomp>r  TselectedrS  Zcollect)rS  c                 S   s   i | ]
}|g qS r~   r~   r6  r~   r~   r   r    r   r   empty)setterz2.4.0r  r   r   r   )&r   rA   r  rI   rG   r  r   r   r   r  r  r   r   r   setattrr  	dataspecsr   r   r   rQ   r   _update_datasourcer   r  Z_update_selectedZdocumentr&  r   rR   r   r   Z_held_eventsrJ  r  	renderersr   r'  )!r   r&  r   r  r  r  r   Zallowed_propertiesZmergedZlegend_propsZlpr  columnsZglyph_updatesr  Z
base_glyphr  filteredr	  specZnew_specZold_specZ	new_fieldZ	old_fieldZcds_replacerS  Z
empty_dataZeventlegitemr   r  r'  r~   r~   r   _update_glyph  s    
 

$
.



zElementPlot._update_glyphc                    s   | j d}|du rdS t|jtjsd|jv r|j D ]`\}}d|  tt	t
jrbt	jjdkszt|r:t|d tjr: fdd|jD |_d	|j < q:|jd
krg |_||jvr|j| dS )z
        Attaches renderer to hover tool and processes tooltips to
        ensure datetime data is displayed correctly.
        r   Nr   r   Mr   c                    s(   g | ] \}}|| kr|d  n|fqS ){%F %T}r~   )r   r  fr-  r~   r   r   A  r   z2ElementPlot._postprocess_hover.<locals>.<listcomp>r   r   )r   r   r   r   r*   r   r   r   r   r   r  ru  r  r  r   r	  Z
formattersr  r   )r   r&  r  r   r   r   r~   r  r   _postprocess_hover4  s"    

zElementPlot._postprocess_hoverc              	   C   s  | j r|jn|}| j r@t|dd tg}| ||\}}}	n&| j| j }	| |||	\}}}	|j	}t
   | ||||	}	W d    n1 s0    Y  |d u r| |}|| jd< | | jd< | jd< |j| jd< | |||||	}
d|
v rd|v r|d t
 " | |||
\}}W d    n1 s80    Y  || jd	< t|trb|| jd
< | || t
 & | ||
||||j W d    n1 s0    Y  d S )Nc                 S   s   | j S r   _plot_idr   r~   r~   r   r   N  r   z*ElementPlot._init_glyphs.<locals>.<lambda>previous_idr  cdsr  r  r  r  glyph_renderer)r   r   r  r   r%   get_batched_datar  cyclic_indexget_datar  r(   r  _init_datasourcer   r  r  r  r  r   r   r  r  r   )r   r}   r   r   r  style_element
current_idr   r  r  r   r&  r  r~   r~   r   _init_glyphsI  s2    .


2

zElementPlot._init_glyphsc           	      C   sd  | j r"dd | jj D d }n| jj}t| jj}| | j||}|| _	|| _
|| _| j rf|jn|}t||}|du r| j||||d}| | n8|jd | jd< |j| jd< |jd | jd	< |j| jd
< || jd< | |||| | js| ||| | || | jD ]}|  q| jr6|   | jsP| | |   | | d| _|S )zN
        Initializes a new plot object with the last available frame.
        c                 S   s   g | ]}|r|qS r~   r~   )r   r   r~   r~   r   r   u  r   z/ElementPlot.initialize_plot.<locals>.<listcomp>r   Nr   r   r   r   r   r   r   r}   T) r   r   r   r   r   r*   
wrap_tuplelast_keycompute_rangesr   current_framecurrent_key
match_specr/  r_  r   r   r   r   r   r"  r  r  r  r   
initialize	top_level
init_linksrX  r  _execute_hooksrM  )	r   r   r}   r   r  r   r-  r   r   r~   r~   r   initialize_ploto  s@    



zElementPlot.initialize_plotc              	   C   s  | j d }| j d}| j d }i }| j dd }| jrPt|dd tg}	n|j}	|	| j d< | jol|	|k| _| jr| 	||\}
}}n| 
|||\}
}}| jr|j D ]>\}}||
vr||
|< qt|
| st|jr|j| |
|< qt   | ||
||}W d    n1 s0    Y  |r| |||||}| j d}d|v rjt|drj|d |_t $ | ||||||
 W d    n1 s0    Y  n| js| ||
 d S )	Nr}   r  r  r  c                 S   s   | j S r   r  r   r~   r~   r   r     r   z,ElementPlot._update_glyphs.<locals>.<lambda>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   r   r  r}   r  r  r  r  r!  r   r   r   r   r&  r~   r~   r   _update_glyphs  s<    



0
6zElementPlot._update_glyphsc                 C   sv   | j sdS | dd D ]X\}}|du r*q|D ]@}| |dj}|dr.|jD ]}t|trP|jsP|	  qPq.qdS )zK
        Resets RangeXY streams if norm option is set to framewise
        TNc                 S   s   | j | jfS r   )r'  r   r   r~   r~   r   r     r   z+ElementPlot._reset_ranges.<locals>.<lambda>r   r  )
r  r   r  r  r   r   r   r2   r  ru   )r   r   r   callbackr   r   r~   r~   r   _reset_ranges  s    

zElementPlot._reset_rangesc                 C   s  |    t| jto| jp| j}| j| _|s@|du r@| |}n|durT|| _	|| _| j
dd}| j
dd}|du}t|dr||_t|dr||_| jr|r|du s| js| js| jr| jd j| jju r| jd jsdS | jr|j}	d}
n|}	| jj}
| |	d}|
r||
n|| _| js:| | j||}n| j| | jjf i | |	dj t|	|}|| _ | j
d }| js| !|	| | "|||	 | #| d| _$d	| j
v r| %| 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   r  r}   Tr   r  )*r1  r   r   r#   r  r   r'  
prev_frame
_get_framer(  r   r   r   r^  rK  r   r   r   r  r   r  Z_max_cyclesr  
max_cyclesr&  r   r'  rD  	set_paramr  r*   r)  r   r  r  rX  r   r   r  r/  r  r-  )r   r-  r   r}   r   reusedr&  r  r^  r   r4  r  r  r~   r~   r   update_frame  sb    






zElementPlot.update_framec                    s<   dd |  dd D }dd |D }t fd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                 S   s   g | ]}|D ]}|qqS r~   r~   )r   Zcbsr   r~   r~   r   r     s   z-ElementPlot.model_changed.<locals>.<listcomp>c                 S   s   | j S r   )r   r   r~   r~   r   r     r   z+ElementPlot.model_changed.<locals>.<lambda>c                 S   s$   g | ]}|j D ]}|jr|jqqS r~   )r   Z	_metadata)r   r   rQ  r~   r~   r   r     s   c                 3   s.   | ]&}|  D ]}|d   jd  kV  qqdS )idN)r   ref)r   r   Zmdmodelr~   r   r   !  s   z,ElementPlot.model_changed.<locals>.<genexpr>)r   r   )r   r;  r   Zstream_metadatar~   r:  r   r    s    zElementPlot.model_changedc                    s8   dd   dd D }t|}t fd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                 S   s0   g | ](}|r| d d tgng D ]}|q"qS )c                 S   s   | S r   r~   r   r~   r~   r   r   .  r   z2ElementPlot.framewise.<locals>.<listcomp>.<lambda>)r   r%   )r   r  r   r~   r~   r   r   -  s
   z)ElementPlot.framewise.<locals>.<listcomp>c                 S   s   | j S r   )r'  r   r~   r~   r   r   -  r   z'ElementPlot.framewise.<locals>.<lambda>c                 3   s"   | ]}  |d jdV  qdS )r   r  N)r  r  r   )r   framer  r~   r   r   1  s   z(ElementPlot.framewise.<locals>.<genexpr>)r   r*   r   r   )r   Zcurrent_framesr~   r  r   r  %  s
    
zElementPlot.framewise)N)N)N)N)F)N)N)NNNN)NNN)Zr  
__module____qualname__rD  ListrV  ObjectSelectorr8  NumberrO  Z	ParameterrG  rH  Integerrj   rk   rE  rF  r<  r=  r:  r;  r9  rI  rZ  Dictr  r   rA  Booleanr!  r  r   r   r%  ClassSelectorr*   r   r   r   rx  ry  r   r  r  r   r  r  Z_stream_datar   r   r   r   r   r   r   r  r/  r(  rL  rX  r]  r_  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r"  r.  r/  r1  r7  r  propertyr  __classcell__r~   r~   r   r   r]   P   s   
	A
m
-6
g

 

+

 

O&
0)
;r]   c                   @   s:   e Zd ZdZi Zg ZdddZdd Zdd Zd	d
 Z	dS )CompositeElementPlotzi
    A CompositeElementPlot is an Element plot type that coordinates
    drawing of multiple glyphs.
    Nc              
   C   sH  d ||fv r,| j | j }| |||\}}}tt|fi || j}i }	|j}
|
| jd< |D ]}| j	d
|dd d }t|}|	|i }t " | |||||}W d    n1 s0    Y  t||	v r|	t| }n| |}||	t|< || j|d < | ||||||}| |||	|i }t , | ||	|i ||\}}W d    n1 sp0    Y  || j|d < t|tr|| j|d < | || t . | |||	|i |||j W d    q\1 s0    Y  q\t| ddrDt| j D ]0\}}|d	s*q| |||d d
  qd S )Nr  r   r   _source_glyph_glyph_renderercolorbarFcolor_mapper)r  r  r  rM   r  _draw_orderr  r   _style_groupsr   r  splitr(   r  r8  r  r  _process_propertiesr  r   r   r  r  r   r  r   r   r  _draw_colorbar)r   r}   r   r   r  r   r  r  r   Zsource_cacher!  r-  style_groupgroup_styleZds_datar   r&  r  r   r   r~   r~   r   r"  A  sF    

 0
<&z!CompositeElementPlot._init_glyphsc           	      C   s   d|v r d |dd d n|}| j| }i }| D ]\\}}|| jv r|dd }||kr:||v rr|| }d |ddd  }nq:|||< q:|S )Nr   r   r   r;   )r  rQ  rP  r   r  )	r   r-  r   r  rT  Zgroup_propsr   r   rp  r~   r~   r   rR  n  s    $


z(CompositeElementPlot._process_propertiesc              
   C   s  | j d }| j dd }| jr6t|dd tg}n|j}|| j d< | joR||k| _| 	|||\}}}t
t|fi || j}	|	D ]&}
||
}| j |
d  }| j |
d }|rt|}| jd|
dd d }t " | |||||}W d    n1 s0    Y  | ||||||}| |
|||
 }| j |
d	 }t ( | ||||
 ||| W d    n1 s0    Y  q| js|d ur| || qd S )
Nr}   r  c                 S   s   | j S r   r  r   r~   r~   r   r     r   z5CompositeElementPlot._update_glyphs.<locals>.<lambda>rI  rJ  r   r   rK  )r   r   r   r  r   r%   r  rK  r   r  rM   r  rO  rP  r  rQ  r(   r  r  rR  r  r
  )r   r   r   r  r}   r  r!  r   r  r   r-  Zgdatar  r  rU  rT  r   r&  r~   r~   r   r/    s6    



 2&z#CompositeElementPlot._update_glyphsc                 C   sJ   t |}d|ddd }t||f i t|fi |}||jfS )r  r   Nr   )rA   r  rQ  r  r  r  )r   r}   r  r   r-  r  r&  r~   r~   r   r    s     z CompositeElementPlot._init_glyph)NNN)
r  r=  r>  __doc__rP  rO  r"  rR  r/  r  r~   r~   r~   r   rH  5  s   
-!rH  c                       s  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fe	j
jdkrefnd ddZejdejeefddZejdddZejejejfdddZejdeeefddZejdejeefddZejdg ddd Zejdd!dZejeedd"d#Z ej!i d$dZ"ej!i d%dZ#ejdd&dZ$ejdd'dZ%e&d(d)d(d*Z'd+Z(e)d,d-g Z*d;d/d0Z+d<d2d3Z,d=d5d6Z-d7d8 Z. fd9d:Z/  Z0S )>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.
    rv   locationr   r   )posr   ry   rx   
horizontal)rX  orientationrw   rb   	top_righttop_leftbottom_leftbottom_right)rv   ry   r@  r?  r]  r^  r_  r`  Nr5   r~   z
        Number of discrete colors to use when colormapping or a set of color
        intervals defining the range of values to map each color to.r{   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.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.)r_   lengthr`   Fz
        Percentile value to compute colorscale robust to outliers. If
        True, uses 2nd and 98th percentile; otherwise uses the specified
        numerical percentile value.linear)rb  r   eq_histz?
        Color normalization to be applied during colormapping.rd   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.re   r_   r`   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.z<
        Whether to make the colormap symmetric around zero.Zblack   )Zbar_line_colorZlabel_standoffrb  z#8b8b8br  paletter  c                 C   s  t rt|t rd S tr0t|tr0tr0t|d}n"t|trL|jdkrLt }nt }t| j	| j
 }|d }tdd t||g D rd S | jr| jd| ji | jd ur| jdt| jdi d	D ]4}| j|d
dd}|d ur| jd|i  qqdD ]:}	| j|	d
dd}
|
d ur | jd|
i  q<q t|d f||d| j}tf i t|fi | j}||| || j|d < d S )N)mapperr   rZ  c                 s   s   | ]}t |tV  qd S r   )r   r	   )r   r;  r~   r~   r   r     r   z.ColorbarPlot._draw_colorbar.<locals>.<genexpr>rl   rl  r7  )Zcticksrk  Frc  rZ  ra  )clabelr.  title_text_font_sizer   )rM  re  rL  )r   r   rY   rZ   r   r  r   r   r  colorbar_specscolorbar_positionr   r  rh  colorbar_optsr'  
cformatterrU   r\  r   _colorbar_defaultsr	   
add_layoutr   )r   r}   rM  r  re  Z	cbar_optsrZ  Ztkr  Zlbr  r   Z	color_barr~   r~   r   rS  
  s>    


zColorbarPlot._draw_colorbarrM  c	                    s  d u r|d u rd S t }	jrjfdd}
fdd|
D }
|
r|
d \}sv|rr|d rr|d nd S jd< S d S |d u rd nt|}rtdd jD rj\}}n|	|v r\jrd	||	 v r||	 d	 \}}n||	 d
 \}}||	 d \}}tj	|ddrtj	|ddrt	|rt	|rt
|t
| }}n,ttrxtjtj }}n|j\}}jrtt||}| | }}tjd rƈjd n|}tjd rjd n|}nd\}}|d u rdn|d }|p&||d |dd dd j D t trt } fdd|D }ttrj|v r|jjntnjfdd|D }n|d u}tjt
r̈j}nJtjtrtjd }t trt |krtd|t f t  ||d}tjtrNt!|j||fd\}\}}"|||\}}jd urj#|kr|_#fdd| D }|rވj$f i | n&|f d|i|j< jd< S )Nc                    s*   | j d| j  dd | j  D fS )N	color_dimc                 S   s   g | ]}t |tr|qS r~   )r   r
   r  r~   r~   r   r   A  s   
zCColorbarPlot._get_colormapper.<locals>.<lambda>.<locals>.<listcomp>)r   r   r   r   r   r~   r   r   ?  s   

z/ColorbarPlot._get_colormapper.<locals>.<lambda>c                    s"   g | ]\}}}| kr||fqS r~   r~   )r   cdimr  mappers)eldimr~   r   r   D  s   z1ColorbarPlot._get_colormapper.<locals>.<listcomp>r   rM  c                 s   s   | ]}t |V  qd S r   )r*   r  )r   Zclr~   r~   r   r   U  r   z0ColorbarPlot._get_colormapper.<locals>.<genexpr>ZrobustZcombinedr   T)Zint_liker;   r  r  r   r  Zviridisc                 S   s   i | ]\}}|t |qS r~   )rC   r  r~   r~   r   r  p  r   z1ColorbarPlot._get_colormapper.<locals>.<dictcomp>c              	      s"   g | ]}  | d jqS )NaN)r   _default_nanr   r  )r  
nan_colorsr   r~   r   r   s  r   c                    s   g | ]} |qS r~   r~   rv  r  r~   r   r   {  r   zwThe number of colors in the colormap must match the intervals defined in the color_levels, expected %d colors found %d.)r  )Zclipc                    s$   i | ]\}}t  ||kr||qS r~   )r  )r   r   opt)r  r~   r   r    s   rf  rp  )%r:   r#  r   r   r   rv  climclim_percentiler*   is_intrh  r   r4   r  nanr   r   	symmetricmaxr  r  r   clipping_colorsr   r  r   rn  r  r  ri  color_levelsr  r8   r9   _get_cmapper_optsrf  r'  )r   rs  r   r   r  r   colorsrp  r   Zdim_namecmappersrr  Zncolorsr  r  ZdlowZdhighZsym_maxr  rf  r  colormapperr   r~   )r  r  rs  rl  r   rw  r   r   r  4  s    



 "



zColorbarPlot._get_colormapperr  c                    s  i i  }}	| | j ||d }
 rXt|
tjr:|
|v sDt|
trX| jd|  d   sd||	fS |	 }t
 j}|rdnd}|d u rt|ts|jj|v rt }||v rd|| v r|| d }n
t|}|d ur|r|jjdkr|d7 }dd |D }d	d |D }|  |||||}|d u rbt|trb|d7 } fd
d|D }d}|||< |d ur| jrttdkrdnd}||	|< ||d|	|< ||	fS )NzaCannot declare style mapping for '%s' option and declare a color_index; ignoring the color_index.ZiOSUZOSUr   r  r  c                 S   s   g | ]}t |qS r~   ri  rv  r~   r~   r   r     r   z0ColorbarPlot._get_color_data.<locals>.<listcomp>c                 S   s   g | ]}t |qS r~   r  rv  r~   r~   r   r     r   c                    s   g | ]}  |qS r~   r  r6  rq  r~   r   r     r   Tr  r  r  r  )r  Zcolor_indexr   r   r*   r   r4   rD  rW  r   r   r   r   r  r  r:   r  r  r   r  rI   rG   )r   r   r   r  r   r   r  Zint_categoriesr   r  r  Zcdatar  Zdtypesr  rg  r  r~   r  r   _get_color_data  sJ    
"

zColorbarPlot._get_color_datac           	         st  |d u r<| j dkrt}| j dks(| jr~t}t|r^t|r^|dkr^d}d vr|d d< qt|r|dkr| jd n| j dkrt	d u rt
d	t	}t|ttjfrt|}t|ttjfrt|}||kr| jd
 }||8 }||7 }i }t|r||d< t|r||d< g d}| fdd|D  n0t}t|}tt|d}d v rl d |d< ||fS )Nrb  r   r   r;   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.rc  zuCould not import bokeh.models.EqHistColorMapper. Note that the option cnorm='eq_hist' requires bokeh 2.2.3 or higher.r5   r  r  ))rt  	nan_color)r~  Z
high_color)r  Z	low_colorc                    s"   i | ]\}}| v r| | qS r~   r~   )r   r   rx  r  r~   r   r    r   z2ColorbarPlot._get_cmapper_opts.<locals>.<dictcomp>)r   rt  r  )cnormr   logzr   r*   r{  r  rD  rW  rY   ImportErrorr   r   r  Zbool_rh  Zdefault_spanr  r'  r   rK   r  r   )	r   r  r  r   r  r  r  r   Z
color_optsr~   r  r   r    sH    





zColorbarPlot._get_cmapper_optsc                    sX   t t| |||}| jrTt| j D ]*\}}|ds<q(| |||dd  q(|S )zQ
        Returns a Bokeh glyph object and optionally creates a colorbar.
        rM  NrN  )	r   rW  r  rL  r   r   r   r  rS  )r   r}   r  r   retr   r   r   r~   r   r    s    
zColorbarPlot._init_glyph)r  )NNNrM  )r  NNF)1r  r=  r>  rV  rj  rD  rE  rh  r   sysversion_infomajorr   r  r*   r   r   r   rm  Stringrh  Tupler  r|  ry  rf  r   rz  r@  r  rD  rL  rk  rC  rl  r  r  r}  r  rn  ru  r>   r  rS  r  r  r  r  rG  r~   r~   r   r   rW    s   

*  
g  
-/rW  c                   @   sp   e Zd Zejg ddddZejdddZejdd	dZ	ej
dd
dZdddddZeji ddZdddZdS )
LegendPlot)r]  r^  r_  r`  rv   ry   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.rd  FzB
        Controls whether the legend entries are muted by default.r^   rY  z
        If legend is placed outside the axis, this determines the
        (width, height) offset in pixels from the original position.z1
       Whether to lay out the legend as columns.rv   ry   rw   rx   )rv   ry   r?  r@  zB
        Allows setting specific styling options for the colorbar.Nc           	      C   s  |p| j d }|jsd S |jd }dd | j  D }t|}|sV| jsVt|jdks\| jslg |jd d < n| jrvdnd|j_	| j
}|| jv rg |jd d < | j|_|dv rd|j_	||| j|  n||_|jD ]6}|jf i | j |jD ]}|jD ]}| j|_qqqd S )	Nr}   r   c                 S   s   g | ]}t |tr|qS r~   )r   r   )r   r  r~   r~   r   r   '  s   
z.LegendPlot._process_legend.<locals>.<listcomp>r;   r[  verticalr?  r@  )r   r  r   r   r  r   r   r  legend_colsr\  legend_positionlegend_specslegend_offsetrX  ro  r'  legend_optsr  legend_mutedmuted)	r   r}   r  r  r  rZ  r  r  r  r~   r~   r   r  "  s0    




zLegendPlot._process_legend)N)r  r=  r>  rD  r@  r  rD  r  ZNumericTupler  rB  r  r  rC  r  r  r~   r~   r~   r   r    s   
r  c                   @   s   e Zd ZdZdS )AnnotationPlotzR
    Mix-in plotting subclass for AnnotationPlots which do not have a legend.
    N)r  r=  r>  rV  r~   r~   r~   r   r  B  s   r  c                       s   e Zd ZejdddZedd eD  e ddg Z	ejdddZ
g d	Zed
d Zedd Z fddZg fddZdd Zdd Z fddZdddZdddZ  ZS )r  Fz<
        Whether to display overlaid plots in separate panesr^   c                 C   s   g | ]}d | qS )Zborder_r~   r  r~   r~   r   r   M  r   zOverlayPlot.<listcomp>r>  r  zH
        Whether to split the legend for subplots into multiple legends.)1rj   rk   r   r   r   rN  rZ  r   r!  r  r  r
  rs  r%  rt  rq  rr  rA  rO  r  r  sizing_moderl   Ztitle_formatr  r  r  r  r  Zpaddingr  r  ZxlimZylimZzlimrx  ry  rV  r=  r;  r<  r=  r9  rG  rH  rE  rF  rI  Z	fontscalec                 C   s,   | j  D ]}t|jts
|j  S q
| jS r   )r  r   r   r  r   r   r   r~   r~   r   r  `  s    zOverlayPlot._x_range_typec                 C   s,   | j  D ]}t|jts
|j  S q
| jS r   )r  r   r   r  r   r  r~   r~   r   r  g  s    zOverlayPlot._y_range_typec                    s  j d }dd fddg}tdd |D }dd |D }jrnt|jd	ksnt|d
kr|js||s|tt	 S |jsd S |jd	 }i }
jjdj }| D ]v\}	}
|	tv rd|	vr|	d}d|d d
 d |d
d   }	|	tv rd|	 }	|	dr |	dd  }	|
||	< qj}jr<dnd}|dv rNd}||d< |d ur|jrddd |jD }||d< |dd |dd |jf i | |jv r҈j| }n||_dj vrg j d< j d }dd |D }|jD ]}t|jtr0tt|j n|j}|rt|jtr^|j dd s^q||v r|| }t!t"#|j$|j$ |j$d d < n2|||< |%| |j d vrj d %| qg }g  |D ]d} fd!d|j$D |j$d d < ||v s|j$rtd"d |j$D s"qԈ |j$7  |%| qt!t"#||jd d < j&rt'|| |j(d#d$}g }|jD ]Z}t|jtrd|jv r|%| qzt)f i t||gd%}j*|_|+|| qz|rt)f i t||d%}j*|_|+|| g |jd d < n(|d&v r>t'|| j*|_|+|| |jD ]D}|jf i j, |jD ]$}|j$D ]}j-pz|j.|_.qjq`qDd S )'Nr}   c                 S   s   | S r   r~   r   r~   r~   r   r   p  r   z-OverlayPlot._process_legend.<locals>.<lambda>c                    s   |  uS r   r~   r   r  r~   r   r   p  r   c                 s   s*   | ]"}t |trt |ts|d uV  qd S r   )r   r  r  r  r~   r~   r   r   q  s   

z.OverlayPlot._process_legend.<locals>.<genexpr>c                 S   s$   g | ]}t |tst |ts|qS r~   )r   r  r  r  r~   r~   r   r   t  s   z/OverlayPlot._process_legend.<locals>.<listcomp>r   r;   r  liner   Zlabel_Zlegend_   r[  r  r  r\  r  c                 S   s   g | ]
}|j qS r~   )r   r  r~   r~   r   r     r   rl   r  Zlabel_text_font_sizeZlegend_titleri  legend_itemsc                 S   s2   i | ]*}t |jtr&tt|j n|j|qS r~   )r   r   r  r  sortedr   )r   r  r~   r~   r   r    s   z/OverlayPlot._process_legend.<locals>.<dictcomp>r   Tc                    s   g | ]}| vr|qS r~   r~   r  )r  r~   r   r     r   c                 s   s   | ]}|j V  qd S r   )r^  r  r~   r~   r   r     r   Fr   )r   )rw   rx   rv   ry   )/r   r   r   r  r   r  rK  r   r  r  r  r   r   r  r   r@   rQ  r  rD   r~  r  r  r   r'  r\  r  rX  r   r   r  r  r  r   r   r*   r   r  r   multiple_legendsrX   r   r   r  ro  r  r  r  )r   overlayr}   r  Zlegend_plotsZnon_annotationr  r  r   r   r   ZksplitrZ  r\  rl   r  Zlegend_labelsr  r   Z	prev_itemr  Zlegend_groupZ
new_legendr  r  r   )r  r   r   r  n  s    



"





&$
"
(








zOverlayPlot._process_legendc                 C   s   i }g g  }}| j  D ]\}}||}|dur||| j}	|	D ]z}
t|
tjr`t|
}nt	|
}t|
t
jr|
jrt|
jnd}||v rqDq|
||< n||v rqDn
|| ||
 qDq|| jd< |S )r   Nr~   r   )r  r   r   r   r   r   r*   r   rH   r   r   r   r   r  r   r   )r   r   r   r   Z
init_toolsZ
tool_typesr-  subplotr   Zel_toolsr   rU  r   r~   r~   r   r     s*    




zOverlayPlot._init_toolsc                 C   s   | j r"d|jv r"|jd | jd< nd|jv rd| jv r|jd }|jrjt|jtjsjtdd |jD }nd}| jd |}|r|jdkrg n|j}|jdkrg n|j}dd || D }t	t
||_d| jvr|| jd< d	S )
zI
        Merges tools on the overlay with those on the subplots.
        r   r   c                 s   s"   | ]\}}|| d dfV  qdS )r  r  Nr  )r   r   r  r~   r~   r   r     r   z+OverlayPlot._merge_tools.<locals>.<genexpr>r~   r   c                 S   s   g | ]}|d ur|qS r   r~   r  r~   r~   r   r   	  r   z,OverlayPlot._merge_tools.<locals>.<listcomp>N)r   r   r   r   r*   r   r  r   r  r   r   )r   r  r   r   r   Ztool_renderersZhover_renderersr  r~   r~   r   _merge_tools  s    

zOverlayPlot._merge_toolsc                 C   s   g g  }}| j  D ]\\}}|j|}|d urt||}|||\}	}
t|	r^||	 t|
r||
 qt	t
t| }t	t
t| }||fS r   )r  r   r   r   r*   r)  r  r   r   r   r   r   )r   r  r   r  r  r   spr   ZelrangesZxfsZyfsr~   r~   r   r  	  s    

zOverlayPlot._get_factorsc                    s0   t | j }|r |d |S tt| |S )Nr   )r   r  r   r   r   r  )r   r   r  r   r~   r   r   	  s    zOverlayPlot._get_axis_dimsNc              
   C   s~  t | jj}dd | jj D }|s0td|d \}}| | j||}| jpht	dd | j
 D | _|d u r| js| js| j||||d}| | || jd< |r| js| ||| | || g }| j
 D ]\}}	d }
| jrd	|	_|	|||}t|tr"||d }
|
|	_||	_| jr4|| jd< | jrr|	j|d	d
}|s`t||
| jj}|t||d | |	 q| jrt|| j | j!| j"| j#| j$| j%dd| jd< n| js| &| | '| d| _(|| jd< | )| jd  d| jv rD| jsD| jd }|j*d | jd< |j+d | jd< |j,| jd< |j-| jd< | j.D ]}|/  qJ| j0rj| 1  | 2| | jd S )Nc                 S   s   g | ]\}}|r||fqS r~   r~   )r   r   r   r~   r~   r   r   $	  r   z/OverlayPlot.initialize_plot.<locals>.<listcomp>z+All Overlays empty, cannot initialize plot.r   c                 s   s   | ]}t |tV  qd S r   )r   rF   )r   r  r~   r~   r   r   *	  r   z.OverlayPlot.initialize_plot.<locals>.<genexpr>r#  r}   F)r   )childrl   fixed)tabsrj   rk   r<  r=  r:  r;  r  Tr   r   r   r   r   r   )3r*   r$  r   r%  r   r   r)   r&  r  r   r  r   r   r/  r_  r   r  r  r  r.  r   r$   r   r'  r(  r$  rL   r   r   r    r  r!   rj   rk   r<  r=  r:  r;  r  rX  rM  Z_update_callbacksr   r   r   r   r   r*  r+  r,  r-  )r   r   r}   r   r-  ZnonemptyZdkeyr   Zpanelsr  r<  r  rl   r   r~   r~   r   r.  "	  sr     










zOverlayPlot.initialize_plotc                    s  |    t| jto| j}| j| _|s:|du r:| |}n|durN|| _|| _|du rZg nt	|j
 }t| jtrz|}n| j}|dur| |||}| |dj | j|d| jdd} jf i  fdd| D  | jjf i   | js| js| js| || dd | jD | j D ]\}}	d}
t| jtr|r| jrZ|}
nJ|dur| ||	||\}}}|dur||\}}
|s| |	| rtfd	d
|	jD r|	| jvrԐq,|	j|||
d q,| jsXt| jtrX|rXd| jd i}| js(| jd |d< | j |||fi | | jsX| jsX| !| |r| js| js| js| 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}   Fr0  c                    s"   i | ]\}}| vr||d  qS )r   r~   r  )r   r~   r   r  	  r   z,OverlayPlot.update_frame.<locals>.<dictcomp>c                 S   s   g | ]}|j r|qS r~   r  r  r~   r~   r   r   	  r   z,OverlayPlot.update_frame.<locals>.<listcomp>c                 3   s   | ]}| vV  qd S r   r~   r   )
triggeringr~   r   r   	  r   z+OverlayPlot.update_frame.<locals>.<genexpr>)r   r   T)&r1  r   r   r#   r  r'  r2  r3  r(  r   r   r   r&  r  r  rC  _propagate_optionsr'  rD  r5  r  r   r  r   r  Z_match_subplotr  Z_update_subplotrv  Zdynamic_subplotsr7  r   Z_create_dynamic_subplotsr  r  rX  r   r-  )r   r-  r   r   r6  r   Z	range_objZ	inheritedr   r  r   idxr  exactr   Zinit_kwargsr}   r~   )r   r  r   r7  g	  sl    
"

 



zOverlayPlot.update_frame)NNN)NN)r  r=  r>  rD  rD  r  r?   r@   rD   r  r  r  rF  r  r  r  r   r  r  r   r.  r7  rG  r~   r~   r   r   r  H  s&   

i
Er  )Z
__future__r   r   r   r  r)  	itertoolsr   typesr   rD  Znumpyr  r   Zbokeh.plottingZbokeh.core.propertiesr   Zbokeh.document.eventsr   Zbokeh.modelsr	   r
   r   r   r   r   Zbokeh.models.axesr   r   Zbokeh.models.formattersr   r   r   Zbokeh.models.mappersr   r   r   Zbokeh.models.rangesr   r   r   Zbokeh.models.tickersr   r   r   r   r   Zbokeh.models.toolsr   Zbokeh.models.widgetsr    r!   corer#   r$   r%   r&   r'   Zcore.optionsr(   r)   r*   r   r+   r,   r-   r.   r/   r0   r   r1   r2   r3   Zutil.transformr4   r}   r6   r7   r8   r9   r:   r   r<   r=   Zstylesr>   r?   r@   rA   rB   rC   rD   rE   ZtabularrF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   r  rZ   Z_known_aliasesr[   	ExceptionZbokeh.plotting._toolsZbokeh.plotting.helpersr\   r]   rH  rW  r  objectr  r  r~   r~   r~   r   <module>   s     (P


           pv  [>