
    LeM^                       d Z ddlZddlZddlmZ ddlmZmZ ddlm	Z	 ddl
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mZ dd
lmZ ddlmZ ddlmZmZ ddl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*m+Z+ ddl,m-Z-m.Z.m/Z/ ddl0m1Z1m2Z2 ddl3m4Z4m5Z5 ddl6m7Z7m8Z8 ddl9m:Z: ddl;m<Z<m=Z=m>Z>m?Z? ddl@mAZA ddlmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZP  G d dejQ                  ZR G d d          ZS G d d eR          ZT G d! d"          ZU G d# d$eT          ZV G d% d&eV          ZW G d' d(eT          ZX G d) d*eX          ZY G d+ d,eR          ZZdS )-z
Public API for all plots supported by HoloViews, regardless of
plotting package or backend. Every plotting classes must be a subclass
of this Plot baseclass.
    N)literal_eval)Counterdefaultdict)partial)groupbyproduct)config)unlocked)pushstate)JupyterComm   )	traversalutil)Datasetdisable_pipeline)Element	Element3D)EmptyLayoutNdLayout)
CompositorSkipRenderingStorelookup_options)CompositeOverlay	NdOverlayOverlay)
DynamicMapHoloMap)isfinitestream_parameters)GraphTable)NoOpSelectionDisplay)RangeXRangeXYRangeYStream)dim   )attach_streamscompute_overlayable_zordersdim_axis_labeldynamic_updateget_axis_paddingget_dynamic_modeget_minimum_spanget_nested_plot_frameget_nested_streamsget_plot_frame	get_rangeinitialize_unboundedscale_fontsizesplit_dmap_overlaytraverse_setterc                   b    e Zd ZdZdZg Zg Zd fd	Zed             Z	d Z
ed             Zed             Zej        d             Zed	             Zej        d
             Zed             Zej        d             ZddZd Zd Zd Zd Zd Zd Zed             Zd Zed             Z xZS )Plotz
    Base class of all Plot classes in HoloViews, designed to be
    general enough to use any plotting package or backend.
    Nc                 l     fd|                                 D             } t                      j        di | |r|n(t          j         j                                                  _        d _        d  _	        d  _
        d  _        d  _        g  _        g  _                             |           d S )Nc                 .    i | ]\  }}|j         v ||S  param.0kvselfs      7lib/python3.11/site-packages/holoviews/plotting/plot.py
<dictcomp>z!Plot.__init__.<locals>.<dictcomp>D   s1     & & &41a$*__ Q$__    Fr@   )itemssuper__init__r   	renderersbackendinstancerenderer_force_comm	_document_root_pane_triggering_triggerset_root)rG   rQ   rootparams	__class__s   `   rH   rM   zPlot.__init__C   s    & & & &6<<>> & & &""6"""$,Z%/$,2O2X2X2Z2Z


drJ   c                     t           )z
        The plotting state that gets updated via the update method and
        used by the renderer to generate output.
        NotImplementedErrorrG   s    rH   r   z
Plot.stateR   s
     "!rJ   c                 N    |dS |                      d           D ]	}||_        
dS )z6
        Sets the root model on all subplots.
        Nc                     | S Nr@   xs    rH   <lambda>zPlot.set_root.<locals>.<lambda>a   s    A rJ   )traverserU   )rG   rZ   plots      rH   rY   zPlot.set_root[   s>     <FMM++.. 	 	DDJJ	 	rJ   c                 P    | j         r| j         S d| j        v r| j        r| j        S d S )Nrh   )rU   handles	top_levelr   r`   s    rH   rZ   z	Plot.roote   s5    : 	:t|###:4rJ   c                     | j         S rc   )rT   r`   s    rH   documentzPlot.documento   s
    ~rJ   c                 2   |rt          |d          r| j        | j                            d          u rt	          | t
                    s|                    | j                   | j        rxt	          | j        j	        j
        t                    r*| j        j	        j
                            | j                   n*| j        j	        j
                            | j        d            || _        | j        r%| j                                        D ]}|||_        d S d S )Non_session_destroyedrh   )hasattrrZ   rj   get
isinstanceGenericAdjointLayoutPlotro   _session_destroyrT   	callbacks_session_destroyed_callbackssetdiscardpopsubplotsvaluesrm   )rG   docrh   s      rH   rm   zPlot.documents   s!    	kGC!788 	kI))&11114!9:: 2$$T%:;;;~ kdn6SUXYY kN,IQQRVRghhhhN,IMMdNceijjj= 	(,,.. ( (#$'DM	( 	(( (rJ   c                     | j         S rc   )rV   r`   s    rH   panez	Plot.pane   
    zrJ   c                 V   t           j        dk    r| j        r| j        j        d         t          j        vrct          | j        t                    rIddl	m
}  |t          j                    j                  }|g ft          j        | j        j        d         <   || _        | j        r| j                                        D ]y}|||_        ||j        st%          |dg           D ]R}t'          |d          r@t%          |dd           r/t)          |j        |j        j        d                   |j        _        Szd S | j        rdt%          | dg           D ]T}t'          |d          r@t%          |dd           r/t)          |j        | j        j        d                   |j        _        Sd S d S )	Ndisableidr   )display)
display_idru   	_on_errorcomm)r	   console_outputrZ   refr   _handlesrr   r   r   IPython.displayr   uuiduuid4hexrV   rz   r{   r~   getattrrp   r   r   )rG   r~   r   handlerh   cbs         rH   r~   z	Plot.pane   s   !Y..49.IM$u~55ty+.. 6//////W
(8999F392,EN49=./
= 	U,,.. Y Y# $DI<ty<!$R88 Y YBt[11 Ygb&$6O6O Y,3DNDIMRVDW,X,X)YY Y Y 	UdK44 U U4-- U'"fd2K2K U(/	d@S(T(TBG%	U 	UU UrJ   c                     | j         S rc   )rS   r`   s    rH   r   z	Plot.comm   r   rJ   c                 p    || _         | j        r%| j                                        D ]}|||_        d S d S rc   )rS   rz   r{   r   )rG   r   rh   s      rH   r   z	Plot.comm   sR    
= 	%,,.. % %# $DI	% 	%% %rJ   c                     t           )z3
        Initialize the matplotlib figure.
        r^   )rG   rangess     rH   initialize_plotzPlot.initialize_plot   
     "!rJ   c                     | j         S )z
        Update the internal state of the Plot to represent the given
        key tuple (where integers represent frames). Returns this
        state.
        r   rG   keys     rH   updatezPlot.update   s     zrJ   c                     |                      d t          g          D ]T}t          |t          t          t
          f          s%t          |j                  D ]}fd|j        D             |_        UdS )z^
        Cleans up references to the plot on the attached Stream
        subscribers.
        c                     | S rc   r@   rd   s    rH   rf   zPlot.cleanup.<locals>.<lambda>   s     rJ   c                 r    g | ]3\  }}t          j        |          rt          j        |          v/||f4S r@   )r   is_param_methodget_method_owner)rD   p
subscriberplotss      rH   
<listcomp>z Plot.cleanup.<locals>.<listcomp>   sV     ' ' '(5:/
;;' )*55UBB 
OBBBrJ   N)	rg   r=   rr   GenericCompositePlotGenericElementPlotGenericOverlayPlotrw   streams_subscribers)rG   rh   streamr   s      @rH   cleanupzPlot.cleanup   s    
 kkD622 	 	Dd%9;MOa$bcc dl++  ' ' ' '9?9L' ' '##	 	rJ   c                 .    |                                   d S rc   )r   )rG   session_contexts     rH   rt   zPlot._session_destroy   s    rJ   c                 (   	  j         j        dk    rt          j         j                  si xj        d                      d t          g          D             z  c_         j        r- j        j        r! j        	                     j
                   dS  j        D ]&\  }}d|_        |j                            |           '	 t           dd            j        r j        n j        d         } fd j        D             }t#          |          	t%          	fd	t'           j        |          D                       }t+          j        | j         j                  }                     |            j        r                                  n# t4          $ r}|d}~ww xY w j        D ]%\  }}d
|_        |j                                         &g  _        dS #  j        D ]%\  }}d
|_        |j                                         &g  _        w xY w)z
        Refreshes the plot by rerendering it and then pushing
        the updated data if the plot has an associated Comm.
        serverc                 p    g | ]3}t          |d g           D ]}|j        	|t          |j                  f 4S )r   )r   rW   dict	_metadata)rD   r   ss      rH   r   z Plot.refresh.<locals>.<listcomp>   sg     !V !V !VA*1!Y*C*C!V !V%&q}!V!T!+%6%6!7 !V !V !V !VrJ   c                     | S rc   r@   rd   s    rH   rf   zPlot.refresh.<locals>.<lambda>   s    YZ rJ   NTrR   r   c                 T    g | ]$}t          fd |j        D                       "|%S )c              3   *   K   | ]}|j         v V  d S rc   )
dimensions)rD   crG   s     rH   	<genexpr>z*Plot.refresh.<locals>.<listcomp>.<genexpr>   s*      !P!P1!t"6!P!P!P!P!P!PrJ   )anycontents)rD   r   rG   s     rH   r   z Plot.refresh.<locals>.<listcomp>   sS     R R Rf!!P!P!P!P!P!P!PPPR6 R R RrJ   c              3   .   K   | ]\  }}|v rd n|V  d S rc   r@   )rD   drE   stream_paramss      rH   r   zPlot.refresh.<locals>.<genexpr>   sI       ? ? Aq !"] 2 2 ? ? ? ? ? ?rJ   F)rQ   moder   
_unblockedrm   rW   rg   r=   r   add_next_tick_callbackrefreshr   r   r;   current_keykeysr   r#   tuplezipr   r   wrap_tuple_streams_trigger_refreshrk   r   	Exceptionclear)
rG   kwargsr   metadatar   dim_streams
stream_keye_r   s
   `        @rH   r   zPlot.refresh   s   
 =))%2B4=2Q2Q) !V !V{{]a\bAcAc !V !V !V V } !> 44T\BBB  + 	) 	)KAx AMKx((((	"D(D111&*&6H$""DIaLCR R R R R R RK-k::M ? ? ? ?$'$=$=? ? ? ? ?C0dot|TTJ !!*---~ 		 	 	 	G	 ( $ $1 %!!####!D ( $ $1 %!!####!D!!!!s+   CF G 
F"FF""G 6Hc                     | j         rt          | t                    r>t                      5  |                     |           ddd           dS # 1 swxY w Y   dS dS )z,Triggers update to a plot on a refresh eventN)rk   rr   r   r
   r   r   s     rH   r   zPlot._trigger_refresh   s     ~ 	!D2D!E!E 	! ! !C   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !	! 	!s   AAAc                    | j         }|rD| j        =|j        d         | j        j        v r$| j        j        |j        d                  d         }nd}| j        j        dk    r#|!| j                            |           |_        dS | j        j        dk    r5|r5d|j	        vr.| j
        r)| j        r$t          | j
        | j                   dS dS dS dS dS dS )z6
        Pushes plot updates to the frontend.
        Nr   r,   bokehr   embedded)rU   r~   r   _plotsrQ   rO   get_plot_stateobjectr   tagsrm   r   r   )rG   rZ   
child_panes      rH   r   z	Plot.push  s     z 	TY*HTNdi...)$(4.9!<JJJ= G++
0F $ < <T B BJm H,,,	))dm)	)	***** -,,,))))))rJ   c                 P    | j         r| j         j        nt          | j                  S rc   )r   r   r   r`   s    rH   r   zPlot.id  s    #y<ty||bnn<rJ   c                     t           z?
        Returns the total number of available frames.
        r^   r`   s    rH   __len__zPlot.__len__  r   rJ   c                 .    t          ||| j                  S rc   )r   rO   )clsobjgroups      rH   r   zPlot.lookup_options  s    c5#+666rJ   NNrc   )__name__
__module____qualname____doc__rO   
style_opts_disabled_optsrM   propertyr   rY   rZ   rm   setterr~   r   r   r   r   rt   r   r   r   r   r   classmethodr   __classcell__r\   s   @rH   r=   r=   4   s         
 G J N      " " X"     X   X _( ( _("   X 
[U U [U.   X 
[% % [%" " " "       '" '" '"T! ! !+ + +" = = X=" " " 7 7 [7 7 7 7 7rJ   r=   c                   b     e Zd ZdZg ZddZd Zd Zd Zd Z	 fdZ
d	 Zed
             Z xZS )PlotSelectorz
    Proxy that allows dynamic selection of a plotting class based on a
    function of the plotted object. Behaves like a Plot class and
    presents the same parameterized interface.
    Fc                     || _         t          |          | _        |                     | j                                        |          }|\  | _        | _        dS )z
        The selector function accepts a component instance and returns
        the appropriate key to index plot_classes dictionary.
        N)selectorr   plot_classes_define_interfacer{   r   plot_options)rG   r   r   allow_mismatch	interfaces        rH   rM   zPlotSelector.__init__-  sT    
 ! ..**4+<+C+C+E+E~VV	-6****rJ   c                 N    |                      |          }t          |dd           S )Nselection_display)get_plot_classr   )rG   r   	plt_classs      rH   r   zPlotSelector.selection_display7  s(    '',,	y"5t<<<rJ   c                 x   d |D             }d |D             |sMt          fdD                       s2fdD             }|D ]}t          d|           t          d          d |D             |s*t          fdD                       st          d	          d
 |D             }d D             |fS )Nc                 x    g | ]7}d  |j                                                                         D             8S )c                 H    i | ]\  }}|j         |j         dk    ||j          S Nr   )
precedencerD   rE   rF   s      rH   rI   z=PlotSelector._define_interface.<locals>.<listcomp>.<dictcomp><  s@     K K K#!AL0ala6G6G 6G6G6GrJ   )rB   objectsrK   rD   rh   s     rH   r   z2PlotSelector._define_interface.<locals>.<listcomp><  s]     ) ) )K K1C1C1E1E1K1K1M1M K K K ) ) )rJ   c                 P    g | ]#}t          |                                          $S r@   )rw   r   )rD   r[   s     rH   r   z2PlotSelector._define_interface.<locals>.<listcomp>?  s(    BBBVc&++--((BBBrJ   c              3   0   K   | ]}|d          k    V  dS r   Nr@   rD   pset
param_setss     rH   r   z1PlotSelector._define_interface.<locals>.<genexpr>@  s,      )W)WD$*Q-*?)W)W)W)W)W)WrJ   c                 ,    g | ]}|d          k    |S r   r@   r  s     rH   r   z2PlotSelector._define_interface.<locals>.<listcomp>B  s(    UUUtzRS}?T?T?T?T?TrJ   zMismatching plot options:z=All selectable plot classes must have identical plot options.c                     g | ]	}|j         
S r@   )r   r  s     rH   r   z2PlotSelector._define_interface.<locals>.<listcomp>I  s    333T333rJ   c              3   0   K   | ]}|d          k    V  dS r  r@   )rD   stylestyless     rH   r   z1PlotSelector._define_interface.<locals>.<genexpr>K  s,      )Q)Q%6!9*<)Q)Q)Q)Q)Q)QrJ   z>All selectable plot classes must have identical style options.c                 H    i | ]}|                                 D ]\  }}||	 S r@   )rK   )rD   r[   r   rF   s       rH   rI   z2PlotSelector._define_interface.<locals>.<dictcomp>N  s3    PPPPPAq!PPPPrJ   c                     g | ]	}|D ]}|
S r@   r@   )rD   r  r   s      rH   r   z2PlotSelector._define_interface.<locals>.<listcomp>O  s%    555eu55!5555rJ   )allprintr   )	rG   r   r   
parametersmismatching_setsmismatch_setplot_paramsr  r  s	          @@rH   r   zPlotSelector._define_interface;  s2   ) )"') ) )
 CBzBBB
 	]c)W)W)W)WJ)W)W)W&W&W 	]UUUUUUU !1 A A1<@@@@[\\\33U333 	^c)Q)Q)Q)Q&)Q)Q)Q&Q&Q 	^\]]]PP*PPP55v555{BBrJ   c                 >    |                      |          } ||fi |S rc   )r   )rG   r   r   
plot_classs       rH   __call__zPlotSelector.__call__Q  s-    ((--
z#(((((rJ   c                     |                      |          }|| j        vr@d}t          ||d                    | j                                                  fz            | j        |         S )Nz*Key %s returned by selector not in set: %s, )r   r   r   joinr   )rG   r   r   msgs       rH   r   zPlotSelector.get_plot_classU  sg    mmC  d'''>CCC43D3I3I3K3K)L)L#MMNNN %%rJ   c           	          	 t                                          ||          S # t          $ rM t          dd                    d | j        d                                         D                       z            w xY w)Nz2Please set class parameters directly on classes %sr  c              3   4   K   | ]}t          |          V  d S rc   )str)rD   r   s     rH   r   z+PlotSelector.__setattr__.<locals>.<genexpr>a  s(      'c'cSC'c'c'c'c'c'crJ   r   )rL   __setattr__r   r  __dict__r{   )rG   labelvaluer\   s      rH   r   zPlotSelector.__setattr__\  s    	e77&&ue444 	e 	e 	eP"ii'c'cDM.<Y<`<`<b<b'c'c'cccd e e e	es
   !% AA<c                     | j         S rc   r   r`   s    rH   r[   zPlotSelector.paramsc  s      rJ   c                     | j         S rc   r%  r`   s    rH   rB   zPlotSelector.paramf  s      rJ   )F)r   r   r   r   r   rM   r   r   r  r   r   r[   r   rB   r   r   s   @rH   r   r   $  s          N7 7 7 7= = =C C C,) ) )& & &e e e e e! ! ! ! ! X! ! ! ! !rJ   r   c                       e Zd ZdZ ej        ddd          Z ej        dd          Zg dZ	 ej
        dd	          Z ej        d
d          Z ej
        dd          Z ej        dd          Z	 	 	 d% fd	Zd Zd Zd Zd&dZd'dZd(dZd(dZd Zd)dZd Zd Zed             Zed              Zed&d!            Zd" Z d# Z!d$ Z" xZ#S )*DimensionedPlotz
    DimensionedPlot implements a number of useful methods
    to compute dimension ranges and titles containing the
    dimension values.
    NTa  
       Specifies various font sizes of the displayed text.

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

          {'ticks':20, 'title':15,
           'ylabel':5, 'xlabel':5, 'zlabel':5,
           'legend':8, 'legend_title':13}

       You can set the font size of 'zlabel', 'ylabel' and 'xlabel'
       together using the 'labels' key.)default
allow_Noner|   z%
       Scales the size of all fonts.r)  r|   )xlabelylabelzlabelclabellabelsxticksyticksztickscticksticksminor_xticksminor_yticksminor_tickstitlelegendlegend_titlez+
        Whether to display the plot title.z{label} {group}
{dimensions}z
        The formatting string for the title of this plot, allows defining
        a label group separator and dimension labels.z
        Whether to compute ranges across all Elements at this level
        of plotting. Allows selecting normalization at different levels
        for nested data containers.a  
        Allows supplying a custom projection to transform the axis
        coordinates during display. Example projections include '3d'
        and 'polar' projections supported by some backends. Depending
        on the backend custom, projection objects may be supplied.Fr   c                 J   |	| _         || _        || _        || _        || _        || _        ||nt          |          | _        || _        |
| _	        d| _
        i | _        d | _        d | _        d | _        d | _        i | _        d| _         t%                      j        di | d S )NFr@   )rz   adjoinedr   
layout_numlayout_dimensionssubplotlistr   uniformdynamicdrawnrj   r   r"  current_framer   r   _updatedrL   rM   )rG   r   r   r?  rB  r@  r=  r>  r  rz   rC  r[   r\   s               rH   rM   zDimensionedPlot.__init__  s     ! $$!2 LDDd4jj	


!""6"""""rJ   c                 h   t          |t                    r=|t          |           k    r*| j                            dt          |                       | j        s|                                 | j        d<   t          |t                    s| j	        |         }| 
                    |           | j        S )zE
        Get the state of the Plot for a given frame number.
        zShowing last frame available: fig)rr   intlenrB   warningrD  r   rj   r   r   update_framer   )rG   frames     rH   __getitem__zDimensionedPlot.__getitem__  s     eS!! 	Mec$ii&7&7JKD		KKLLLzG1E1E1G1G4<.%'' 	%Ie$E%   zrJ   c                     dS )z
        Required on each MPLPlot type to get the data corresponding
        just to the current frame out from the object.
        Nr@   r   s     rH   
_get_framezDimensionedPlot._get_frame        rJ   c                     t          |          r t          |t                    s ||           S t          |t                    rt          | |          S t          d          )zC
        Matches a specification against the current Plot.
        z6Matching specs have to be either a type or a callable.)callablerr   type
ValueError)rG   specs     rH   matcheszDimensionedPlot.matches  sc     D>> 	W*T4"8"8 	Wd:Kd## 	WJtT,B,B%BUVVVrJ   c                 B   g }|du }|s|D ]}|                      |          }|r n|r"|                    |r ||           n|            t          | d          rD| j        r=| j                                        D ]#}|||                    |||          z  }|s n$|S )a   
        Traverses any nested DimensionedPlot returning a list
        of all plots that match the specs. The specs should
        be supplied as a list of either Plot types or callables,
        which should return a boolean given the plot class.
        Nrz   )rW  appendrp   rz   r{   rg   )rG   fnspecsfull_breadthaccumulatorrW  rV  els           rH   rg   zDimensionedPlot.traverse  s     4- 	" " ",,t,,!EE! 	927rr$xxx4888 4$$ 	+ 	+m**,, + +:r{{2ulCCC#*UU*rJ   r   
c                    | j         $t          | j                                          \  }}nK| j        s| j        rt          |           dk    s| j        rdS t          |t                    r|n|f}| j	        }d t          ||          D             fdt          t                              D             }t          j        |                    d |D                                 S )z_
        Returns the formatted dimension group strings
        for a particular frame.
        Nr,    c                 4    g | ]\  }} |j         |          S r@   )pprint_value_string)rD   r+   rE   s      rH   r   z0DimensionedPlot._frame_title.<locals>.<listcomp>  s6     2 2 2633C3A66 2 2 2rJ   c                 \    g | ](}d                      |z  |dz   z                     )S )r  r,   )r  )rD   idimension_labels
group_sizes     rH   r   z0DimensionedPlot._frame_title.<locals>.<listcomp>  sM     9 9 9 )),Qz\1Q3
:J-JKLL 9 9 9rJ   c              3      K   | ]}||V  	d S rc   r@   )rD   gs     rH   r   z/DimensionedPlot._frame_title.<locals>.<genexpr>  s'      3K3K!3KA3K3K3K3K3K3KrJ   )r?  r   rK   rC  rB  rJ  r@  rr   r   r   ranger   bytes_to_unicoder  )rG   r   rg  	separatorr   groupsrf  s     `   @rH   _frame_titlezDimensionedPlot._frame_title  s   
 !-!4#9#?#?#A#ABOJ 	)t| 	)s4yyA~~$,~2#C//;##cVCJ2 2
C002 2 29 9 9 9 9 %5!6!6779 9 9$Y^^3K3Kv3K3K3K%K%KLLLrJ   c                    |                      |dd          \  }}}}t          j        | j                                      t          j        |          t          j        |          ||          }|                    d          S )NTr_  )r   rl  )r"  r   rT  r   z 
)_format_title_componentsr   rk  r9  formatstrip)	rG   r   r   rl  r"  r   	type_name	dim_titler9  s	            rH   _format_titlezDimensionedPlot._format_title  s    -1-J-JDD .K .
 .
*ui %dj1188'..'.. 	 9 
 
 {{5!!!rJ   c                 F    | j         | j        t          |           j        dfS )z
        Determine components of title as used by _format_title method.

        To be overridden in child classes.

        Return signature: (label, group, type_name, dim_title)
        ra  )r"  r   rT  r   )rG   r   r   rl  s       rH   rp  z(DimensionedPlot._format_title_components  s      
DJT

(;R@@rJ   c                     i S )aN  
        Should returns default fontsize for the following keywords:

            * ticks
            * minor_ticks
            * label
            * title
            * legend
            * legend_title

        However may also provide more specific defaults for
        specific axis label or ticks, e.g. clabel or xticks.
        r@   r`   s    rH   _get_fontsize_defaultsz&DimensionedPlot._get_fontsize_defaults  s	     	rJ   fontsizec           	      ,   | j         s	| j        si S t          | j         t                    s%| j         |r|t	          | j         | j                  iS t          | j         t                    r| j         ni }t          |                                          t          | j                  z
  }|rNd}| j        	                    |t          |          | j        fz             |D ]}|                    |d            |                                 }d }||v r	||         }n|dv r>|                    d|                    ||                    d                              }n|dv r>|                    d|                    ||                    d                              }n[|dv r>|                    d|                    ||                    d                              }n|d	v r|                    |          }|i S |t	          || j                  iS )
Nz@Popping unknown keys %r from fontsize dictionary.
Valid keys: %r)r.  r-  r,  r/  r0  r"  )r1  r2  r3  r4  r5  )r6  r7  r8  )r:  r;  r9  )ry  	fontscalerr   r   r9   rw   r   _fontsize_keysrB   rK  rA  ry   rx  rq   )	rG   r   r"  commonry  unknown_keysr  defaultssizes	            rH   	_fontsizezDimensionedPlot._fontsize  s
   } 	JT^ 	JIDM400 	JT]5NSY5N>$-HHII$.t}d$C$CK4==8==??++c$2E.F.FF 	=UCJstL'9'94;N&OOPPP#<<X\\#t%<%<%<%<..00(??C=DD<<<<<(,,sHLL<Q<Q*R*RSSDD<<<<<c8<<;P;P)Q)QRRDD444<<x||CmA\A\/]/]^^DD777<<$$D<I~dDN;;<<rJ   c                 2   t          | dd          }t          d |                    d t          g          D                       }|	| j        r|ri S || j        nd |                                D             }|                     |          }d }|                                D ]\  }\  }	}
}t          | dd           p|	}	g }|
p| j        pt          |          d	k    }
|
s|                    ||g          }n2|0| 
                    |          }|g n|                    ||g          }|	r,t          |t                    s|
s6t          |t                    r!|                     ||||
|	|| j        |           | j                            |           |S )
a  
        Given an object, a specific key, and the normalization options,
        this method will find the specified normalization options on
        the appropriate OptionTree, group the elements according to
        the selected normalization option (i.e. either per frame or
        over the whole animation) and finally compute the dimension
        ranges in each group. The new set of ranges is returned.
        
prev_frameNc              3   @   K   | ]}t          |t                    V  d S rc   )rr   r%   rD   r^  s     rH   r   z1DimensionedPlot.compute_ranges.<locals>.<genexpr>H  s,      ]]"
2u--]]]]]]rJ   c                     | S rc   r@   rd   s    rH   rf   z0DimensionedPlot.compute_ranges.<locals>.<lambda>H  s    q rJ   c                 4    i | ]\  }}|t          |          S r@   )r   r   s      rH   rI   z2DimensionedPlot.compute_ranges.<locals>.<dictcomp>L  s$    4[4[4[DAqQQ4[4[4[rJ   c                 4    t          | t                    r| nd S rc   )rr   r   rd   s    rH   rf   z0DimensionedPlot.compute_ranges.<locals>.<lambda>U  s    :a#9#9Caat rJ   shared_axesTr,   )r   r  rg   r   	normalizer   rK   _get_norm_optsrC  rJ  rP  rr   r!   _compute_group_rangerk   r   )rG   r   r   r   r  	all_table	norm_opts	return_fnr   axiswise	framewiserobustelementsrM  s                 rH   compute_rangeszDimensionedPlot.compute_ranges>  s    T<66
]][[SZR[8\8\]]]]]	;dn;	;I &4[4[FLLNN4[4[4[ '',,	
 DC	4=OO4E4E 	6 	60E0Hi#D->>>MHHH "GT\GS]]a5GI W<<	E7;;,,!&22ENN9ug4V4V  6jg&>&> 66#-c7#;#;6))%69*2FDN*46 6 6 	6"""rJ   c                 l   i d }d |                     |          D             }d }t          t          ||          |          }|D ]:\  }}|dk    rdn|}d |D             }| j        j        }	t          j        |	                              |t          j        |	                    }
|
D ]}t          |j
                            d	          d
d                   t          fd|D                       }|rd|j        v r||d         j        }|d         j        }d|v sd|v sd|v rV                    |                    dd          |                    dd          |                    dd          fi           Ԑ<d |D             }                    fd|D                        S )al  
        Gets the normalization options for a LabelledData object by
        traversing the object to find elements and their ids.
        The id is then used to select the appropriate OptionsTree,
        accumulating the normalization options into a dictionary.
        Returns a dictionary of normalization options for each
        element in the tree.
        c                     t          | t                    rP| j        t          |           j        t          j        | j        d          t          j        | j	        d          ffnd S )NF)escape)
rr   r   r   rT  r   r   group_sanitizerr   label_sanitizerr"  rd   s    rH   rf   z0DimensionedPlot._get_norm_opts.<locals>.<lambda>x  sg    !W%%!0Q(8$:Nqw_d:e:e:e(,(<QWU(S(S(S(U !V !V+/ rJ   c                 2    h | ]}||d         |d         fS )Nr   r,   r@   )rD   idspecs     rH   	<setcomp>z1DimensionedPlot._get_norm_opts.<locals>.<setcomp>{  s4     0 0 0F". !)VAY/...rJ   c                 &    | d         dn| d         S )Nr   r@   rd   s    rH   rf   z0DimensionedPlot._get_norm_opts.<locals>.<lambda>  s    1221Q4 rJ   r   r  Nc                     g | ]\  }}|S r@   r@   )rD   r   r^  s      rH   r   z2DimensionedPlot._get_norm_opts.<locals>.<listcomp>  s    >>>%!R2>>>rJ   )rO   .r,   c              3   Z   K   | ]%}t          d d          D ]}|d|         k    V  &dS )r,      N)rj  )rD   rV  re  paths      rH   r   z1DimensionedPlot._get_norm_opts.<locals>.<genexpr>  s`       4 44',Q{{4 4"# #d2A2h. 4 4 4 4 4 4 4rJ   normrh   r  r  clim_percentileFc                     g | ]\  }}|S r@   r@   )rD   r   rV  s      rH   r   z2DimensionedPlot._get_norm_opts.<locals>.<listcomp>  s    ;;;'!T;;;rJ   c           	      l    i | ]/t          fd t          dd          D                       ,d0S )c              3   T   K   | ]"}d |                                          v V  #d S rc   )r   )rD   re  r  rV  s     rH   r   z<DimensionedPlot._get_norm_opts.<locals>.<dictcomp>.<genexpr>  s:      $W$WaT"1"X1A1A%A$W$W$W$W$W$WrJ   r,   r  )FFF)r   rj  )rD   rV  r  s    @rH   rI   z2DimensionedPlot._get_norm_opts.<locals>.<dictcomp>  sb     Y Y Y$!$$W$W$W$W$W5QRTU;;$W$W$W!W!WY$ 5 Y Y YrJ   )rg   r   sortedrQ   rO   r   custom_optionsrq   optionsr   r  splitr   rm  r   )rG   r   type_val_fnelement_specskey_fn	id_groupsgidelement_spec_groupgroup_specsrO   optstreeoptsappliesnoptspoptsr  r  s                  @@rH   r  zDimensionedPlot._get_norm_optsl  sc    	0 00 0cll;>W>W 0 0 0
 87F=f===vFF	'0 	X 	X#C#))$$C>>+=>>>Km+G+! ! !!$S%-*H*H*H!I!I  ! 
X 
XTY__S11!""566 4 4 4 4; 4 4 4 4 4 Xv44 L0E L0E!U**kU.B.BFW[`F`F`!(($:u1M1M16;1N1N16;Le1T1T1V *W X X X
X <;];;; Y Y Y Y- Y Y Y 	Z 	Z 	ZrJ   c                    t          j        |d         d          }t          j        |d                   }t          j        |                    dg                     }t          j        |d                   }t          j        |d         |d         ||          }||||||d	}d
|v r|d
         }|rd |D             ng }	t	          |	          dk    rt          t          |	                    nd }
d |D             }|
(	 t          j        ||
          }n# t          $ r Y nw xY wt          j
        |          |d
<   |S )NhardFcombinedsoftr  datar   r,   )r  r  r  r  r  r{   factorsc                     h | ]	}|j         
S r@   dtype)rD   fss     rH   r  z6DimensionedPlot._merge_group_ranges.<locals>.<setcomp>  s    <<<"RX<<<rJ   c                     g | ]	}|D ]}|
S r@   r@   )rD   fctrsrF   s      rH   r   z7DimensionedPlot._merge_group_ranges.<locals>.<listcomp>  s%    BBBeEBBqBBBBrJ   r  )r   	max_rangerq   dimension_rangerJ  nextiternparrayr   unique_array)r   r   
hard_range
soft_rangerobust_range
data_ranger  drangesall_factorsfactor_dtypesr  expandeds               rH   _merge_group_rangesz#DimensionedPlot._merge_group_ranges  sm   ^F6NUCCC
^F6N33
~fjj2&>&>??^F6N33
'
1z!}(2J@ @%z%8)V= =  +K@KS<<<<<<QSM14]1C1Cq1H1HDm,,---dEBB{BBBH !x>>>HH    D!%!28!<!<GIs   D 
D%$D%c	           	        * d |D             }i }	i }
g }|D ]}|                     d          D ]i}t          |d          rrt          |t                    rA||j                                         v r&|j        j                            |j        |          }nX|j                            ||          }n<t          |d          r*t          |          r|                    |          j        }nd }t          d |j
        D                       rd}n||j        dv rd}nt          |t                    r.||j        d d	         v r|j        
                    d	d
          }nK|j        r-t          |j        |          }|
                    |d
          }n|
                    |d
          }||	||f<   ||j        dv r|r}t          |t                    rd	n|}t!          |t"          j        |                              |          t!          |t"          j        d|z
                                |          f|
||f<   t)          d |D                       s,|j        t-          |j        t.                    s||j        dv r|                    |           k|                    |i           }i }|D ]D}t          |t4          t6          f          r |                     |d          }|                     |d          }t;          |j        fi |j        }|                    dd          sz|                                D ]F\  }}t          |t                     r
d|vr|dk    r&t          |t                     r
|                     |          rtC          |          }||v r|sh|                    |d          }d }|j        j        dk    r)|"                                |#                                f}ntI          j%        |          r||f}n|j        j        dv rtI          j&        |          }nt          |          dk    rt"          j'        t"          j'        f}n	 tQ          j)                    5  tQ          j*        dd           t#          j+        |          t#          j,        |          f}d d d            n# 1 swxY w Y   n$# tZ          $ r tI          j&        |          }Y nw xY w||vr
g g g g d||<   |7d||         vrg ||         d<   ||         d                             |           n!||         d                             |           ||         d                             t]          |                     H|                     d          D ]W}|j/        }||v r|s|	||f         }||vrg g g g g d||<   ||         d                             |           ||         d                              |j
                   ||         d!                             |j0                   ||f|
v r)||         d"                             |
||f                    ||v r^d||         vrg ||         d<   |j        g d fvr|j        }n||v r[t          |t                    r.||j        d d	         v r|j                            d	d
#          }nR|                    |d
#          }n:t          |t                    r%||j        v r|j                            |d
#          }t          |t"          j1                  rN|j        j        d$k    r>t          d% |D                       r%t          |          rt#          j2        |          ng }tI          j&        |          }||         d                             |           ||         d                             t]          |                     YFtg          t:                    }|                                D ]M\  }}d}|                                D ]*\  } }!| d&v r
|t          d' |!D                       d	k     z  }+|r|||<   Ng }"|                                D ]1\  }}| 4                    |          }#|"                    ||#f           2|r|s |s|r||5                    d(           *|"D ]\  }$}#|                    |$i                               d)d           }|d|vr/|#                                D ]\  }%}|$|vri ||$<   |||$         |%<   d|                    d          }&i }'|#d)                                         D ]1\  }%}*fd*tm          |&||%                   D             }(|(|z  }(|(|'|%<   2| 4                    |'          ||$<   d S |r|r|s|s|"D ]\  }$}#|#                                D ]{\  }%}|                    |$i                               |%d           })|)|$|vri ||$<   |||$         |%<   F|%d+v r|||$         |%<   VtI          j7        |)|g|%d k    ,          ||$         |%<   |d S t;          |"          ||<   d S )-Nc                     g | ]}||S rc   r@   r  s     rH   r   z8DimensionedPlot._compute_group_range.<locals>.<listcomp>  s    <<<2R^B^^^rJ   r   r   r   c              3   >   K   | ]}t          j        |          V  d S rc   )r   r"   rD   rs     rH   r   z7DimensionedPlot._compute_group_range.<locals>.<genexpr>  s,      >>At}Q''>>>>>>rJ   r   SUra  ra  r   F)r  uifd   c              3   @   K   | ]}t          |t                    V  d S rc   )rr   r  r  s     rH   r   z7DimensionedPlot._compute_group_range.<locals>.<genexpr>  s,      ??q
1c**??????rJ   r  rh   apply_rangesTcolor	magnitude)
all_valuesMUSr   ignorez All-NaN (slice|axis) encountered)r   r  r  r  r  r  r   )r   r  r  r  r  r  r  r  )r  Oc              3   J   K   | ]}t          |t          j                  V  d S rc   )rr   r  ndarrayrD   rF   s     rH   r   z7DimensionedPlot._compute_group_range.<locals>.<genexpr>1  s.      HHAJq2:77HHHHHHrJ   )r  r   c                 |    h | ]9}|D ]4}t          j        |          t          |t           j                  rd nd5:S )datenumber)r   r"   rr   datetime_types)rD   rngrF   s      rH   r  z7DimensionedPlot._compute_group_range.<locals>.<setcomp>?  sj     I I I I I+,t}Q7G7GI:a1D#E#ES8 I I I IrJ   c                      t          |           S rc   r   )os    rH   rf   z6DimensionedPlot._compute_group_range.<locals>.<lambda>N  s    RUU rJ   r{   c                 "    g | ]\  }}|v	|S r@   r@   )rD   re  r  prev_idss      rH   r   z8DimensionedPlot._compute_group_range.<locals>.<listcomp>^  s'    WWWdaQhEVEVEVEVEVrJ   )r  r{   r  )8r   rp   rr   r$   nodesr   r  rJ  dimension_valuesr  rj  kindkdimsr{   r   boolr+   r  nanpercentileapplyr   rT  
issubclassr  rY  rq   r   r%   r   r   r   rK   r  reprminmaxr   isscalarr  nanwarningscatch_warningsfilterwarningsnanminnanmaxr   r   namer  r  concatenater   r  rg   r   r  )+r   r   r  r   r  r  r  rk   r  data_rangesrobust_rangescategorical_dimsr^  el_dimr  r  ds
percentileprev_rangesgroup_rangesr  	plot_opts
opt_kwargsrE   rF   dim_namer{   r  drangegroup_dim_rangesgdimmatchingtrs
dim_rangesr  r   ri  idsmergedfilteredpranger  s+                                             @rH   r  z$DimensionedPlot._compute_group_range  sW   
 =<<<< #	4 #	4B--11 "4 "42{++ !!"e,, ?28;N;N;P;P1P1P " 2 8 86 J J " 2 22v > >R++ !B !//77=EE E>>>>>>> 
I!-JJ&5:+=+=!)JJE** Iv"1"/E/E!#5!I!IJJ] I 77B!#&%!H!HJJ!#&%!H!HJ,6RL)$u)<)<)<&0&>&>!JFJFB$4jAAGGKKFB$4cJ6FGGMMbQQ3M2v,/
 ??J????? 4[,FK1M1M,&5:+=+=$++F333E"4H jj++ P	< P	<B"uen--7x%%b'22D**2v66Idk>>Y-=>>J>>.$77  #((** $@ $@1!!S)) gQ.>.>1CSCSa%%  @!))B--  @#AwwH;..y. WWRDW99F"G|(C//!'vzz||!;v.. @!'*d22"&"3F";";V))!#@!)!8!:!: P P ( 7Be f f f*,)F*;*;RYv=N=N)OP P P P P P P P P P P P P P P  ) @ @ @&*&7&?&?GGG@|33"$b"b2 2X. *$L,BBB@BL29=$X.y9@@IIII$X.v6==fEEE *40772??? --11  <  <!;{**9*("f6
<// "b"PR. .L* X&v.55jAAAX&v.55flCCCX&v.55f6GHHH<=00 *84;;M2v,<WXXX--- X(>>><>X.y9}RJ66!'2%b%00 QVrx|5K5K%'X%>%>q5%>%Q%QFF%'%8%8%%8%P%PFF#B.. S6RX3E3E!#!:!:6E!:!R!R"62:66 O6<;LPS;S;SHHHHHHH <T;>v;;!N!7!7!7B"/77G *95<<WEEEX&t,33BrFF;;;;A <F 't,,(..00 
	0 
	0LD&H  2))) I I$&I I I J JLMN  0)/ & 
,2244 	/ 	/LD&--f55GtWo....  &	-	 &	-X &	-9 &	-I_!**??;;H( A A
7$B//33HdCC>T%7%7%,]]__ 3 3	6K//-/KN,2Aq))jj&& !(!2!8!8!:!: ) )IAvWWWWc#vay.A.AWWWH&H (F1II!$!8!8!@!@A%A A&  	-) 	- 	-h 	-( O O
7!( 
O 
OIAv(__Q33774@@F~K//-/KN,2Aq))333,2Aq)),0NFF;KDEvI-O -O -OAq))
OO O !,,F5MMMs6   &S9>S7SSS
SSS0/S0c                 |     fd}|                     ||          }i }	t          d           }
|D ]\  }                    di           ||	vri |	|<                                   D ];\  }}||	|         vrg |	|         |<   |	|         |                             |           <                                D ]&\  }}|
|         |                             |           '|
                                D ]4\  }                                D ]\  }}||	|         vr||	|         |<   5r|	n|	d         S )a)  
        Traverses the supplied object getting all options in opts for
        the specified opt_type and specs. Also takes into account the
        plotting class defaults for plot options. If a keyfn is
        supplied the returned options will be grouped by the returned
        keys.
        c                                         |           fd	D             dk    rKrIt          j        j                                     t          |                     fd	D             d<   r |           nd}|fS )z
            Looks up options for object, including plot defaults.
            keyfn determines returned key otherwise None key is used.
            c                 >    i | ]}|j         v |j         |         S r@   )r  )rD   r  r  s     rH   rI   zEDimensionedPlot._traverse_options.<locals>.lookup.<locals>.<dictcomp>  s8     ? ? ?go)=)= 7?1-)=)=)=rJ   rh   c                 Z    i | ]'}|vt          |          |t          |          (S r@   )rp   r   )rD   r  rh   selecteds     rH   rI   zEDimensionedPlot._traverse_options.<locals>.lookup.<locals>.<dictcomp>  sK     (S (S (S+,H+<+<qAQAQ+< )*74+;+;+<+<+<rJ   r  N)r   r   registryrO   rq   rT  )
re   r   r  rh   r$  r   r  keyfnopt_typer  s
     @@@rH   lookupz1DimensionedPlot._traverse_options.<locals>.lookup}  s    
 ((H55G? ? ? ?!%? ? ?H6!!h!~ck266tAww??(S (S (S (S (ST (S (S (S$#-%%(((C?"rJ   c                  *    t          t                    S rc   )r   rA  r@   rJ   rH   rf   z3DimensionedPlot._traverse_options.<locals>.<lambda>  s    ;t+<+< rJ   r  N)rg   r   ry   rK   rY  )r   r   r'  r  r[  r&  r  r(  	traversedr  default_optsr   optrF   s   ` `` ``       rH   _traverse_optionsz!DimensionedPlot._traverse_optionst  s   	# 	# 	# 	# 	# 	# 	# 	# 	#  LL//	"#<#<==" 		1 		1ICxx
B//H'!!!**,, , ,Qgcl**(*GCL%S!((++++"..** 1 1QS!#&--a00001 &++-- 	* 	*IC**,, * *Qgcl**()GCL%*  2wwWT]2rJ   c                    d }|                     d t          g          }|rdS |                     |ddgt          t          g|          }t          d |                    di                               dg           D                        }|                    |i                               dg           }d	 |D             }t          t          |                    d
k    rt          d          |r|d         ndS )a^  
        Uses traversal to find the appropriate projection
        for a nested object. Respects projections set on
        Overlays before considering Element based settings,
        before finally looking up the default projection on
        the plot type. If more than one non-None projection
        type is found an exception is raised.
        c                 ,    t          | t                    S rc   )rr   r   rd   s    rH   rf   z1DimensionedPlot._get_projection.<locals>.<lambda>  s    j,<== rJ   c                     | S rc   r@   rd   s    rH   rf   z1DimensionedPlot._get_projection.<locals>.<lambda>  s    1 rJ   3drh   
projection)r&  c              3      K   | ]}|d u V  	d S rc   r@   rD   r   s     rH   r   z2DimensionedPlot._get_projection.<locals>.<genexpr>  s&      [[QqDy[[[[[[rJ   Tc                     g | ]}||S rc   r@   r4  s     rH   r   z3DimensionedPlot._get_projection.<locals>.<listcomp>  s    @@@a!----rJ   r,   z0An axis may only be assigned one projection typer   N)
rg   r   r-  r   r   r  rq   rJ  rw   rU  )r   r   	isoverlay	element3dr  from_overlayprojectionscustom_projss           rH   _get_projectionzDimensionedPlot._get_projection  s    >=	LLyk::	 	4$$S&<.&6%@+4 % 6 6 [[$((42D2D2H2HWY2Z2Z[[[[[[hh|R0044\2FF@@;@@@s<  !!A%%OPPP".8|AD8rJ   c                     t          |           dk    r,|d| j        d         fv r| j        s|                                 S |                     |          }|                     d            |S )Nr,   r   c                 $    t          | dd          S )NrF  T)setattrrd   s    rH   rf   z(DimensionedPlot.update.<locals>.<lambda>  s    :t < < rJ   )rJ  r   rD  r   rN  rg   )rG   r   items      rH   r   zDimensionedPlot.update  sm    t99>>ca1%666tz6'')))$$<<===rJ   c                 *    t          | j                  S r   )rJ  r   r`   s    rH   r   zDimensionedPlot.__len__  s     49~~rJ   )
NNNTFNr   NNF)NNT)r   r_  Tr_  )ry  T)$r   r   r   r   rB   	Parameterry  Numberr{  r|  Boolean
show_titleStringr9  r  r2  rM   rN  rP  rW  rg   rn  ru  rp  rx  r  r  r  r   r  r  r-  r;  r   r   r   r   s   @rH   r(  r(  l  s         ut D+ , , ,H T 0( ) ) )I  N t 2. / / /J EL!@ G9 : : :E d 1' ( ( (I
 ! 4F G G GJ FJHI49# # # # # #,
 
 
  W W W   2M M M M$
" 
" 
" 
"A A A A   = = = =>, , ,\- - -^   [0 }- }- [}-~ +3 +3 +3 [+3Z9 9 9.        rJ   r(  c                   .    e Zd ZdZd Zed             ZdS )CallbackPlotNc                    g }t                      }t          t          j                                                  }t          j        | j                 | j        D ]!fd|D             }|fd|D             z  }"g }t          |d           }t          |d           D ]O\  }}d |D             }	|	D ]}
|
|vr|
                    |
           |
                     || |	                     P||fS )zr
        Initializes any callbacks for streams which have defined
        the plotted object as a source.
        c                 Z    g | ]'\  }}|D ]}|u s|j         |j         j         k    | (S rc   )_plot_id)rD   srcr   r   sources       rH   r   z5CallbackPlot._construct_callbacks.<locals>.<listcomp>  s]     G G G"c7G G34&==S\%=%(\V_%D%D %D%D%D%DrJ   c                 |    h | ]8}t          |          v r%|j        r|j        !t          |                   |f9S rc   )rT  linkedrM  )rD   r   ru   s     rH   r  z4CallbackPlot._construct_callbacks.<locals>.<setcomp>  sR     : : :"6lli77FM7%}8 &d6ll3V<888rJ   c                 ,    t          | d                   S r   r  rd   s    rH   rf   z3CallbackPlot._construct_callbacks.<locals>.<lambda>  s    b1hh rJ   r  c                     | d         S r   r@   rd   s    rH   rf   z3CallbackPlot._construct_callbacks.<locals>.<lambda>  s
    qt rJ   c                     g | ]\  }}|S r@   r@   )rD   r   r   s      rH   r   z5CallbackPlot._construct_callbacks.<locals>.<listcomp>  s    ...1!...rJ   )rw   rA  r*   r%  rK   
_callbacksrO   link_sourcesr  r   rY  )rG   source_streams
cb_classesr%  r   cbs
sorted_cbsr   r   
cb_streams	cb_streamru   rM  s              @@rH   _construct_callbacksz!CallbackPlot._construct_callbacks  s^   
 UU
--//00%dl3	' 	: 	:FG G G G&.G G GG  : : : :7 : : : :JJ J,>,>???
 ^^<< 	5 	5IB.....J' 5 5	N22")))444JJrr$
F334444N""rJ   c           	         t          | t                    rg nQ| j        rBt          t	          | j        | j        t          | j        j                  z                       n| j        gt          | t                    r| j        s| j        j        g}nT| j	        rt          | j        t                    r&fd| j                                        D             }n| j        j        g}|S )z)Returns potential Link or Stream sources.c                 ,    g | ]\  }}|D ]}|v |	S r@   r@   )rD   re  inputsr  zorderss       rH   r   z-CallbackPlot.link_sources.<locals>.<listcomp>  s>     8 8 8YQ &8 8!w,, *6,,,rJ   )rr   r   batchedrA  rj  zorderrJ  hmaplaststaticr    stream_sourcesrK   )rG   sourcesr_  s     @rH   rT  zCallbackPlot.link_sources  s     d.// 	$GG\ 	$5dk#din:M:M.MNNOOGG{mGd.// 	' 	'y~&GG 	'
49j A A 	'8 8 8 8$*=*C*C*E*E 8 8 8GG y~&GrJ   )r   r   r   rO   r[  r   rT  r@   rJ   rH   rH  rH    sC        G# # #6   X  rJ   rH  c                       e Zd ZdZ ej        dd          Z ej        dd          Z ej        e	e
fdd          Z ej        d	eee
fd
          Z ej        g d          Z ej        dd          Z ej        dd          Z ej        dd          Z ej        dd          Z ej        dd          Z ej        deee
fd          Z ej        d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        e j!        e j!        fd d!"          Z" ej        e j!        e j!        fd d!"          Z# ej        e j!        e j!        f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*i Z+g Z,dZ-d*d+d,d-d.d/Z. e/            Z0dZ1	 	 	 dB fd1	Z2d2 Z3d3 Z4d4 Z5d5 Z6d6 Z7d7 Z8d8 Z9d9 Z:d: Z;dCd<Z<dDd=Z=dEd?Z>d@ Z?dFdAZ@ xZAS )Gr   z
    Plotting baseclass to render contents of an Element. Implements
    methods to get the correct frame given a HoloMap, axis labels and
    extents and titles.
    TzA
        Whether to compute the plot bounds from the data itself.r+  z:
        Whether to apply extent overrides on the ElementsNzC
        If set bgcolor overrides the background color of the axis.)class_r)  r|          @a+  
        Defines the span of an axis if the axis range is zero, i.e. if
        the lower and upper end of an axis are equal or no range is
        defined at all. For example if there is a single datapoint at
        0 a default_span of 2.0 will result in axis ranges spanning
        from -1 to 1.)r)  rh  r|   z
        Optional list of hooks called when finalizing a plot. The
        hook is passed the plot object and the displayed element, and
        other plotting handles can be accessed via plot.handles.Fz,
        Whether to invert the x- and y-axisz+
        Whether to invert the plot x-axis.z+
        Whether to invert the plot y-axis.z;
        Whether the x-axis of the plot will be a log axis.z;
        Whether the y-axis of the plot will be a log axis.g?an  
        Fraction by which to increase auto-ranged extents to make
        datapoints more visible around borders.

        To compute padding, the axis whose screen size is largest is
        chosen, and the range of that axis is increased by the
        specified fraction along each axis.  Other axes are then
        padded ensuring that the amount of screen space devoted to
        padding is equal for all axes. If specified as a tuple, the
        int or float values in the tuple will be used for padding in
        each axis, in order (x,y or x,y,z).

        For example, for padding=0.2 on a 800x800-pixel plot, an x-axis
        with the range [0,10] will be padded by 20% to be [-1,11], while
        a y-axis with a range [0,1000] will be padded to be [-100,1100],
        which should make the padding be approximately the same number of
        pixels. But if the same plot is changed to have a height of only
        200, the y-range will then be [-400,1400] so that the y-axis
        padding will still match that of the x-axis.

        It is also possible to declare non-equal padding value for the
        lower and upper bound of an axis by supplying nested tuples,
        e.g. padding=(0.1, (0, 0.1)) will pad the x-axis lower and
        upper bound as well as the y-axis upper bound by a fraction of
        0.1 while the y-axis lower bound is not padded at all.-
        Whether to show legend for the plot.z6
        Whether to show a Cartesian grid on the plot.bottom)toprk  bareztop-barezbottom-bareNTFz
        Whether and where to display the xaxis.
        The "bare" options allow suppressing all axis labels, including ticks and xlabel.
        Valid options are 'top', 'bottom', 'bare', 'top-bare' and 'bottom-bare'.)r)  r   r|   left)rn  rightrm  z	left-barez
right-bareNTFz
        Whether and where to display the yaxis.
        The "bare" options allow suppressing all axis labels, including ticks and ylabel.
        Valid options are 'left', 'right', 'bare', 'left-bare' and 'right-bare'.zl
        An explicit override of the x-axis label, if set takes precedence
        over the dimension label.zl
        An explicit override of the y-axis label, if set takes precedence
        over the dimension label.r   z
       User-specified x-axis range limits for the plot, as a tuple (low,high).
       If specified, takes precedence over data and dimension ranges.)r)  lengthr|   z
       User-specified z-axis range limits for the plot, as a tuple (low,high).
       If specified, takes precedence over data and dimension ranges.)r   ih  z&
        Rotation angle of the xticks.)r)  boundsr|   z&
        Rotation angle of the yticks.z
        Ticks along x-axis specified as an integer, explicit list of
        tick locations, or bokeh Ticker object. If set to None default
        bokeh ticking behavior is applied.z
        Ticks along y-axis specified as an integer, explicit list of
        tick locations, or bokeh Ticker object. If set to None
        default bokeh ticking behavior is applied.zThe `color_index` parameter is deprecated in favor of color style mapping, e.g. `color=dim('color')` or `line_color=dim('color')`zdThe `size_index` parameter is deprecated in favor of size style mapping, e.g. `size=dim('size')**2`.zyThe `scaling_method` parameter is deprecated in favor of size style mapping, e.g. `size=dim('size')**2` for area scaling.zhThe `scaling_factor` parameter is deprecated in favor of size style mapping, e.g. `size=dim('size')*10`.zcThe `size_fn` parameter is deprecated in favor of size style mapping, e.g. `size=abs(dim('size'))`.)color_index
size_indexscaling_methodscaling_factorsize_fnr   c                 .    |i }|
i }
| _         | _        | _        |
 _        t	          |t
          t          f          s t          d|fdg|j                   _        n| _        |r| _	        nt           j                   _	         j        j        }|rt	           t                    s|j        }t	          |t                    o|j         }|d u  _         j        r7 j        j        }t!           j        j                                                  }|	                     |d          n|	 _                             |d          j         j                                        } j        r6t!          t3          |          t3          t          j                  z
            } j        rD                     |d|d          } j        di fd|                                D              t?          |fi }|                                D ]>\  }}| j         v r0| j!        v r'|% j         "                     j!        |                    ? tG                      j$        d|||d	| | _%        |tM           j                  n| _'         j        s1 j%        rt	           t                    rtQ            j                    j%        rtS          j*         j                   _+                              j        j        d          j                                        } fd
|D             }  j         j        di |                      |d          ,                    t[           j+                             _        d S g  _+        d S )Nr   Frame)initial_itemsr  r   r  rh   F)r  c                 0    i | ]\  }}|v	||d          S r	  r@   )rD   rE   rF   r  s      rH   rI   z/GenericElementPlot.__init__.<locals>.<dictcomp>  s7      7  7  7DAq#$I#5#5 !"1Q4#5#5#5rJ   )r   r   rC  c                 .    i | ]\  }}|j         v ||S r@   rA   rC   s      rH   rI   z/GenericElementPlot.__init__.<locals>.<dictcomp>  s&    EEETQQ$*__Aq___rJ   r@   ).ra  cyclic_indexoverlaidoverlay_dimsrr   r!   r    r   rb  re  r.   rc  r   	unboundedrk   r  rA  r  r   r   r  r  _propagate_optionscopy_multi_y_propagationrw   _multi_y_unpropagatedv17_option_propagationr-  r   rK   r   rB   _deprecationsrK  rL   rM   r`  r5   r   r-   r   
layer_sortordering
max_cyclesrJ  )rG   elementr   r   r   r`  r}  r|  ra  r  r~  re  r   r[   plot_elementrC  propagate_options	inheritedapplied_paramsr   pvaloverlay_optsr  r  r\   s   `                      @rH   rM   zGenericElementPlot.__init__  s    !NL( ('GZ#899 	 q'l&-Y7:? ? ?DII  DI 	I"0D"=di"H"HDy~ 	-:d,>?? 	-',LWj11K':K6K> 	/J	++--..DCH=T((w???V[
''f==E	 388::$ 	m $S):%;%;cBTBj>k>k%k l l& 	8..|V/@8= / ? ?I I 8 8  7  7  7  7IOO4E4E  7  7  7 8 8 8 f22	22%++-- 	: 	:GAtDJ1(:#:#:t?O
""4#5a#8999 	<dz!(	< 	<,:	< 	< 	<8?)$)444W  	,$, 	,z$HZ7[7[ 	,4+++ < 	 ODI66DM..ty~vFFNTTVVLEEEE\EEEDDJ%%%%%,,\7CCNNsSWS`OaOabbDJJJDMMMrJ   c                 b    t          j        |||          }| j                            |          S )z}
        Computes the z-order of element in the NdOverlay
        taking into account possible batching of elements.
        )r   get_overlay_specr  index)rG   overlayr   r^  rV  s        rH   
get_zorderzGenericElementPlot.get_zorder  s.    
 $Wc266}""4(((rJ   c                      fdj                                         D             }t          t           j        |z                        _         fd|D             S )Nc                 B    g | ]\  }}t          j        ||          S r@   )r   r  )rD   r   r^  r  s      rH   r   z7GenericElementPlot._updated_zorders.<locals>.<listcomp>  s<     6 6 6S" &wR88 6 6 6rJ   c                 D    g | ]}j                             |          S r@   )r  r  )rD   rV  rG   s     rH   r   z7GenericElementPlot._updated_zorders.<locals>.<listcomp>  s)    <<<d##D))<<<rJ   )r  rK   r  rw   r  )rG   r  r[  s   `` rH   _updated_zordersz#GenericElementPlot._updated_zorders  sr    6 6 6 6 ' 2 2 4 46 6 6s4=#67788<<<<e<<<<rJ   c                 z    |                                 dd         }t          |          dk    r|ddgz   S |dgz   S )z
        Returns the dimensions corresponding to each axis.

        Should return a list of dimensions or list of lists of
        dimensions, which will be formatted to label the axis
        and to link axes.
        Nr   r,   )r   rJ  )rG   r  dimss      rH   _get_axis_dimsz!GenericElementPlot._get_axis_dims  sH     !!##BQB't99>>4,&&4&= rJ   c                 d    |                      |          }t          fd|D                       S )Nc              3   V   K   | ]#}t          |t                    r|v n|k    V  $d S rc   )rr   rA  )rD   r  	dimensions     rH   r   z9GenericElementPlot._has_axis_dimension.<locals>.<genexpr>  sR       
 
  *"d33HIOOb
 
 
 
 
 
rJ   )r  r   )rG   r  r  r  s     ` rH   _has_axis_dimensionz&GenericElementPlot._has_axis_dimension  sN    ""7++ 
 
 
 

 
 
 
 
 	
rJ   c                 D   t          | j        t                    r| j        r| j        r|| _        | j        S || j        k    r| j        s| j        S | j        d u ot          d | j        D                        }t          t          d | j        D             |                    }t          | j        ||          }t          | dd           || j        vr>t          |          | j        j        k    r!| j        r| j                            |           || _        || _        |S )Nc              3   $   K   | ]}|j         V  d S rc   )rW   )rD   r   s     rH   r   z0GenericElementPlot._get_frame.<locals>.<genexpr>  s$      5Z5Zam5Z5Z5Z5Z5Z5ZrJ   c                     g | ]	}|j         
S r@   r  rD   r   s     rH   r   z1GenericElementPlot._get_frame.<locals>.<listcomp>      <<<qAF<<<rJ   rR   F)rr   rb  r    r}  rE  r   rR   r   r   r   r   r   r6   r;   r   rJ  ndimsrC  rY  )rG   r   cachedkey_maprM  s        rH   rP  zGenericElementPlot._get_frame	  s&   di,, 	& 	&4CU 	&"D%%D$$$T[$%%!T)Z#5Z5ZT\5Z5Z5Z2Z2Z.Zs<<DO<<<cBBCCty'6::h...diCHH	$?$?DL$?IS!!!"rJ   c                     | j         D ]F}	  || |           # t          $ r*}| j                            d|d|            Y d}~?d}~ww xY wdS )z)
        Executes finalize hooks
        zPlotting hook z could not be applied:

 N)hooksr   rB   rK  )rG   r  hookr   s       rH   _execute_hooksz!GenericElementPlot._execute_hooks  s     J 	8 	8D8T7#### 8 8 8
"" $7D $7 $734$7 $7 8 8 8 8 8 8 8 88	8 	8s   
A AAc                     dS )z=
        Should define the aspect ratio of the plot.
        Nr@   )rG   xspanyspans      rH   
get_aspectzGenericElementPlot.get_aspect&  rQ  rJ   c                    |\  }}}}}}|                      |d          j                            d          }	| j        rd}
n|	}| j                            d          d         j        | j        ur| j        }
nK|                     |ddgt          gd          }|                    d          }
|
r	|
d         }
n
| j        }
n|	}
t          |
          \  }}}| j        s| j        st          j        |          rt          j        |          r||z
  nd}t          j        |          rt          j        |          r||z
  nd}|                     ||          dk    r6t          |t                     rt!          fd	|D                       n|z  }n5t          |t                     rt!          fd
|D                       n|z  }|||fS )zV
        Computes padding along the axes taking into account the plot aspect.
        rh   paddingr   NexistingT)r[  r  r,   c              3   "   K   | ]	}|z  V  
d S rc   r@   )rD   xpaspects     rH   r   z1GenericElementPlot.get_padding.<locals>.<genexpr>G  '      662RY666666rJ   c              3   "   K   | ]	}|z  V  
d S rc   r@   )rD   ypr  s     rH   r   z1GenericElementPlot.get_padding.<locals>.<genexpr>I  r  rJ   )r   r   rq   r}  rB   r   r)  r  r-  r   r1   r`  r   	is_numberr  rr   r   )rG   r   extentsx0y0z0x1y1z1padding_optr  r  xpadypadzpadr  r  r  s                    @rH   get_paddingzGenericElementPlot.get_padding+  s    $+ RRR))#v66=AA)LL= 	"GG z!!*--i8@TT,--)WI .   ((9-- +%ajGG"lGG!G+G44dD} 	cT\ 	c!^B//PDN24F4FPBrEEDE!^B//PDN24F4FPBrEEDE__UE22Fzz:DT5:Q:Qbu6666666666W[\bWb:DT5:Q:Qbu6666666666W[\bWbT4rJ   c           	      H   |                                 }t          |          }|p|r|d         nd }|p|dk    r|d         nd }t          | j        t                    r| j        dk    r|p|dk    r|d         nd }nd }t          |||          \  \  }	}
}}t          |||          \  \  }}}}t          |||          \  \  }}}}d}| j        s| j        sd t          | j	                  D             \  }}}t          |	|
|          \  }}|	|k    s|
|k    r||}
}	d}t          |||          \  }}||k    s||k    r||}}d}t          |||          \  }}|                     ||	|||
||f          \  }} }!|dk    r|\  }	}
n?|d	k    r|\  }	}
n3|d
k    rd\  }	}
n'|dk    r!t          j        |	|
|||| j                  \  }	}
|dk    r|\  }}nZ|d	k    r|\  }}nN|dk    r"t          j        ||||| | j                  \  }}n&|d
k    rd\  }}n|t           j        t           j        }}t          | j        t                    ry| j        dk    rn|dk    r|\  }}nZ|dk    r|\  }}nN|dk    r"t          j        |||||!| j                  \  }}n&|d
k    rd\  }}n|t           j        t           j        }}|	|||
||fS | j        s[t)          | dg           D ]I}"t          |"t*          t,          t.          f          r%|r#|"| j        vr| j                            |"           J|	||
|fS )Nr   r,   r1  r   Fc              3       K   | ]	}|d z  V  
dS ri  Nr@   r  s     rH   r   z8GenericElementPlot._get_range_extents.<locals>.<genexpr>\  s&      "U"UA1R4"U"U"U"U"U"UrJ   Tr  r  categoricalr  r  r  rU  )r   rJ  rr   r2  r  r7   r}  r`  r1   default_spanr3   r  r   r  logxlogyr  r  logzrD  r   r'   r)   r(   rX   rY  )#rG   r  r   
range_typexdimydimzdimr  r  r  r  xsrangexhranger  r  ysrangeyhranger  r  zsrangezhrangetriggerr  r  zspanmx0mx1my0my1mz0mz1r  r  r  r   s#                                      rH   _get_range_extentsz%GenericElementPlot._get_range_extentsL  s   !!##D		352Qd75199Q$dos++ 	40G0G;uqyyDGGdDDD%.w%E%E"R'7%.w%E%E"R'7%.w%E%E"R'7} 	7T\ 	7"U"U1A$BS1T1T"U"U"UE5%'B66HCSyyB#IIcB'B66HCSyyB#IIcB'B66HC++Gb"b"b"5MNNdDFB6!!FB]""FB:%%)"b'7D$)TTFBFB6!!FB:%%)"b'7D$)TTFB]""FB\VRVBdos++ 	,40G0GV## BBv%% BBZ''-b"gwdiXXBB&&BBBBB++z 	1!$(8"== 1 1v'@AA 11 &dm ; ;M((000BBrJ   r  c                    t          | j        t                    r| j        dk    rdnd}	| j        r|dv r|                     |d          j        }
|
                    dd          s| j        r|j        }nk| j	        
                    d t          g          }t          j        |t          | j        t                    o
| j        dk              }nt          j        f|	z  }|d	k    r|S | j        r|                     ||||||          }nt          j        f|	z  }t%          | d
d          rB| j        r;t          j        ||gt          | j        t                    o
| j        dk              }nag }t)          ||          D ]?\  }}t+          |          r|                    |           *|                    |           @t/          |          }t          | j        t                    r| j        dk    r
|\  }}}}}}n|\  }}}}t          j        ||| j        d          \  }}t          j        ||| j        d          \  }}| j        s| j        r||f||ffn||f||ff\  }}t%          | dg           D ]}t          |t:                    rd|i}n6t          |t<                    rd|i}nt          |t>                    r||d}nR |j         di | || j!        vr(| j        s| j        r| j!                            |           t          | j        t                    r2| j        dk    r't          j        ||| j"        d          \  }}||||||fS ||||fS )a%  
        Gets the extents for the axes from the current Element. The globally
        computed ranges can optionally override the extents.

        The extents are computed by combining the data ranges, extents
        and dimension ranges. Each of these can be obtained individually
        by setting the range_type to one of:

        * 'data': Just the data ranges
        * 'extents': Element.extents
        * 'soft': Dimension.soft_range values
        * 'hard': Dimension.range values

        To obtain the combined range, which includes range padding the
        default may be used:

        * 'combined': All the range types combined and padding applied

        This allows Overlay plots to obtain each range and combine them
        appropriately for all the objects in the overlay.
        r1     r  )r  r  r  r  Fc                     | j         S rc   )r  rd   s    rH   rf   z0GenericElementPlot.get_extents.<locals>.<lambda>  s    19 rJ   r  r  r   rU  x_rangey_range)r  r  r@   )#rr   r2  r  apply_extentsr   r  rq   rC  r  rb  rg   r   r   max_extentsr  r  r  r  r   r@  r   r"   rY  r   r  xlimylimrD  invert_axesr'   r)   r(   r   rX   zlim)rG   r  r   r  r  r  r  r  r   numr  r  extent_listrange_extentsr  
max_extentl1l2r  r  r  r  r  r  r  r  r   r[   s                               rH   get_extentszGenericElementPlot.get_extents  s   , t44XD9P9PaaWX 	&*0G"G"G++GV<<DI}}[%00 DL !/"i001D1DwiPP*t44PD9P 
 vi#oG""N 	, 33GVZQUW[]abbMMVIOM4.. 	)4< 	)'(4?C00LT_5L HH
 JmW55 * *BB<< *%%b))))%%b))))Z((Hdos++ 	&40G0G%-"BBB%NBB%b"diFFB%b"diFFBz 	17;7GaR2r(33rSUhY[]_X`MaGW!$(8"== 1 1ff-- '1FF// '1FF00 )0WEEFF'''''..DI..M((000dos++ 	,40G0G)"b$)\JJFBBB++BBrJ   c                    | j         | j         }n|r||d         }|rt          |          nd}| j        | j        }n0t          |          dk    r||d         }|rt          |          nd}t	          | dd           | j        }nYt          | j        t                    r?| j        dk    r4t          |          dk    r!||d         rt          |d                   nd}|||fS )Nr   ra  r   r,   r.  r1     )	r,  r/   r-  rJ  r   r.  rr   r2  r  )rG   r   r,  r-  r.  xdimsydimss          rH   _get_axis_labelsz#GenericElementPlot._get_axis_labels  s   ;"[FF 	<FNqME.3;^E***F;"[FF__!!fnqME.3;^E***F44((4[FF#.. 	L4?d3J3Jj//Q&&6>6@mK^JqM222Fvv%%rJ   r_  c                     |                      |          }|dS t          |          j        }|j        |k    r|j        nd}|j        }| j        s|r|                     ||          }nd}||||fS )N)ra  ra  ra  ra  ra  )rl  )rP  rT  r   r   r"  r?  rn  )	rG   r   r   rl  rM  rs  r   r"  rt  s	            rH   rp  z+GenericElementPlot._format_title_components  s    $$=##KK(	${i77R! 	Z 	))#)CCIIIui33rJ   c                 	   |                     d          }t          |          dk     r | j                            d|d           dS |d         }|                    |          p|}|| j        v r| j        |         nt          ||          rt          ||          n^| j                            | dt          |           j	        d|d	t          | j                                                  d
           dS |dd         D ]mdv rT                    d          r>                    d          }|dz   d         }	 d|v r|                     d          }|d         dk    rdnt          |d                   }	|d         dk    rdnt          |d                   }
t          |          dk     s|d         dk    rdnt          |d                   }t          |	|
|          }n3d|v r d |                     d          D             }nt!          |          }n5# t"          $ r( | j                            d|d|d           dY  n"w xY wd|         nd}dv rdv r                    d          }                    d          }|dz   |         }	 |r|                     d          }g i |D ]}d|v rO|                     d          \  }}t!          |                                          |                                <   U                    t!          |                                                     ndi n4# t"          $ r' | j                            d|d|d           dY  nw xY wd|         t)          t                    s t                    i nfdD             |9t)          |t                    s                    |          nfd|D             |d         dk    st                    s7| j                            ddt                    j	        d           d nt                    o|d         }|fS ) z
        Parses a custom option of the form 'model.accessor.option'
        and returns the corresponding model and accessor.
        r  r   zCustom option z0 expects at least two accessors separated by '.'Nr   z  model could not be resolved on z plot. Ensure the zA custom option spec references a valid model in the plot.handles z$ or on the underlying figure object.r,   r  []:ra  r  ,c                 P    g | ]#}t          |                                          $S r@   )r   rr  )rD   r?  s     rH   r   z9GenericElementPlot._parse_backend_opt.<locals>.<listcomp>;  s(    &f&f&fd|DJJLL'A'A&f&f&frJ   zCould not evaluate getitem z in custom option spec ()=r@   z$Could not evaluate method arguments c                 <    g | ]} t          |          i S r@   )r   )rD   maccmethod_argsmethod_kwargss     rH   r   z9GenericElementPlot._parse_backend_opt.<locals>.<listcomp>j  s1    [[[PQ_WQ__kK]KK[[[rJ   c                 :    g | ]}                     |          S r@   )rN  )rD   re  models     rH   r   z9GenericElementPlot._parse_backend_opt.<locals>.<listcomp>p  s'     K K K!!2!21!5!5 K K KrJ   zCould not resolve z attribute on zO model. Ensure the custom option spec you provided references a valid submodel.)r  rJ  rB   rK  rq   rj   rp   r   rT  r   rA  r   endswithr  rI  slicer   r   rr  rY  rr   rN  )rG   r,  rh   model_accessor_aliases	accessorsmodel_accessorgetitem_indexgetitem_specslice_partsslice_start
slice_stop
slice_stepgetitem_accmethod_ini_indexmethod_end_indexmethod_specmethod_partspartr   r#  attr_accessorr  r  r  r	  s                        @@@@rH   _parse_backend_optz%GenericElementPlot._parse_backend_opt  s   
 IIcNN	y>>AJ  @  @  @  @ A A AF"1 033NCCU~T\))L0EET>** 	D.11EEJ! " "4jj)" "!" " !%T\%6%6%8%8 9 9	" " "   FQrT? V	( V	(C czzcll3//z #		#"=?2#56l**&2&8&8&=&=.9!n.B.BddKXYNH[H[-8^r-A-ATTs;WX>GZGZ
-0-=-=-A-A[QR^WYEYEYTT_bcnopcq_r_r
&+KZ&P&P,,&f&flN`N`adNeNe&f&f&f '3<&@&@    J&&:l : :14: : :; ; ; !EEE .=.)"czzcSjj#&99S>> #&99S>> !"2Q"67G"GH" +'2'8'8'='=&((*$0 O OD"d{{-1ZZ__
U=I%++--=X=Xciikk : : !, 2 2<

3M3M N N N NO ')(*    J&&:{ : :14: : :; ; ; !EEE +++, "%.. \/GE3//NNNEE[[[[[[UZ[[[E*%k488 L % 1 1+ > > K K K K{ K K K*++,byyEM5#&& 
""4 4 4E{{+4 4 4   E3''EE!"m##s&   CH((-II,B,M-N
	N
c                     dS )a  
        Set the plot(s) to the given frame number.  Operates by
        manipulating the matplotlib objects held in the self._handles
        dictionary.

        If n is greater than the number of available frames, update
        using the last available frame.
        Nr@   )rG   r   r   s      rH   rL  zGenericElementPlot.update_frame  rQ  rJ   )NNNFr   r   r   NNNN)r  NNNNNNNrA  rc   )Br   r   r   r   rB   rD  r  r  ClassSelectorr  r   bgcolorrI  floatr  HookListr  r  invert_xaxisinvert_yaxisr  r  r  show_legend	show_gridObjectSelectorxaxisyaxisrF  r,  r-  Tupler  r  r  r  r  Integer	xrotation	yrotationrB  r1  r2  _plot_methodsr  r  r  r&   _selection_displayr  rM   r  r  r  r  rP  r  r  r  r  r  r  rp  r  rL  r   r   s   @rH   r   r     sJ         !5= 4D E E EL "EM$ 5= > > >M "e!#ut JF G G GG '5&sC;N U   L EN2 ,D E E EE
  %- 4/ 0 0 0K !5= 5. / / /L !5= 5. / / /L 5= -> ? ? ?D 5= -> ? ? ?D "e!#sE56I PB C C CG4  %- 30 1 1 1K e 29 : : :I !E *L *L *LRTU U UE !E /P /P /PVTU U UE U\$ -% & & &F U\$ -% & & &F 5;/ @I J J JD 5;/ @I J J JD 5;/ @I J J JD d8 B) * * *I d8 B) * * *I U_T 0. / / /F
 U_T 06 7 7 7F M
 !T9J9;% M. .-// CGLPAED D D D D DN) ) )= = =! ! !
 
 
  $	8 	8 	8  
     BD  D  D LT  T  T  T l& & & &(4 4 4 4x$ x$ x$t       rJ   r   c                        e Zd ZdZ ej        dd          Z ej        dd          Z ej        dd          Z	 ej        dd	          Z
g Zg d
Zd fd	ZddZd Zd Zd Zd Zd ZddZddZ xZS )r   a  
    Plotting baseclass to render (Nd)Overlay objects. It implements
    methods to handle the creation of ElementPlots, coordinating style
    groupings and zorder for all layers across a HoloMap. It also
    allows collapsing of layers via the Compositor.
    Tz
        Whether to plot Elements NdOverlay in a batched plotting call
        if possible. Disables legends and zorder may not be preserved.r+     z?
        Number of rendered glyphs before legends are disabled.rj  r   a  
        The length of the type.group.label spec that will be used to
        group Elements into style groups.  A style_grouping value of
        1 will group just by type, a value of 2 will group by type and
        group, and a value of 3 will group by the full specification.)r)  r  r$  r  Nc                     d|vr                      |          |d<    t                      j        |f|||d| d j        v rk j        rd j        D ]\}t          |j                  h dz  }|r? j                            t          |          j	         dt          |           d           ]                      j        | j                   _        t                       _        |t                      n| _        i  _        d _                             |           _                              fd           |d u  _        g  _         j        r!                      fd	t0          g           d S d S )
Nr2  )r   r   r`  multi_y>   yrq  boundsyy_selectionz stream parameters z$ not yet supported with multi_y=Truer   c                 0    t          | dj                  S )Nr   )r>  r   re   rG   s    rH   rf   z-GenericOverlayPlot.__init__.<locals>.<lambda>  s    649 = = rJ   c                 0    t          | j        d          S )Nr   )r-   rb  r8  s    rH   rf   z-GenericOverlayPlot.__init__.<locals>.<lambda>  s    N4$C$C rJ   )r;  rL   rM   rB   r3  r   rw   rK  rT  r   rA  _apply_compositorrb  r   r   map_lengthsgroup_countercyclic_index_lookupzoffset_create_subplotsrz   rg   rk   dynamic_subplotsr   )
rG   r  r   r`  r   r<  r[   r   intersectionr\   s
   `        rH   rM   zGenericOverlayPlot.__init__  s   v%%#'#7#7#@#@F<  	4d!(	4 	4,2	4 	4 	4 ###\ e e #AG/X/X/X X eJ&&$q''*: (d (d+/+=+=(d (d (d e e e **49fdiHH	"99*7*?WYYY]#% --f55====>>> "> 	0MMCCCC-.0 0 0 0 0	0 	0rJ   c                 ^   	
 j         dk    oj        d         j        dk    }|rSrQrO|sMfdj        D             		fd|D             }t           fdt	          ||          D                       }nK                     dd          
t          
 fdj                                        D                       }|                                t                      5  t          j        |                                fd	
          }ddd           n# 1 swxY w Y   |S )z
        Given a HoloMap compute the appropriate (mapwise or framewise)
        ranges in order to apply the Compositor collapse operations in
        display mode (data collapse should already have happened).
        r,   r   rx  c                 :    g | ]}                     |          S r@   )r  )rD   r   r   s     rH   r   z8GenericOverlayPlot._apply_compositor.<locals>.<listcomp>  s'    CCC
((++CCCrJ   c                 H    g | ]t          fd D                       S )c              3   (   K   | ]}|         V  d S rc   r@   )rD   re  rE   s     rH   r   zBGenericOverlayPlot._apply_compositor.<locals>.<listcomp>.<genexpr>  s'       8 8!1 8 8 8 8 8 8rJ   )r   )rD   rE   dim_indss    @rH   r   z8GenericOverlayPlot._apply_compositor.<locals>.<listcomp>  s7    GGGQ5 8 8 8 8x 8 8 888GGGrJ   c           	          g | ]?\  }}|j                                         v  |                    ||                   f@S r@   )r  r   r  )rD   r   slckeyholomapr   rG   s      rH   r   z8GenericOverlayPlot._apply_compositor.<locals>.<listcomp>  sa     !t !t !t,7CU[_f_k_p_p_r_rUrUr #)$*=*=gsFSVK*X*X!YUrUrUrrJ   Nc                 B    g | ]}|                     |          fS r@   )r  )rD   r   rI  mapwise_rangesrG   s     rH   r   z8GenericOverlayPlot._apply_compositor.<locals>.<listcomp>  sF     !H !H !H,/ #&t':':7C'X'X!Y !H !H !HrJ   r   )r   )r  r  r  r   r   r  r  r   r{   r   r   collapse)rG   rI  r   r   r   
defaultdimsliced_keysframe_ranges	collapsedrF  rK  s   ``` `    @@rH   r:  z$GenericOverlayPlot._apply_compositor  s    ]a'LGM!,<,AW,L
 	IF 	Iz 	I* 	ICCCCW]CCCHGGGG$GGGK !t !t !t !t !t !t;>t[;Q;Q!t !t !t u uLL "00$EEN !H !H !H !H !H !H3:<3D3D3F3F!H !H !H I IL$$&& 	d 	d"+Gfl>O>O>Q>Q5RYbcccI	d 	d 	d 	d 	d 	d 	d 	d 	d 	d 	d 	d 	d 	d 	ds   *,D""D&)D&c                 H   t          j        | j                  }| j        ot	          | j        j                  t          u }|r@| j        j        }t          j
        |                             | j        j        j                  }|r=|r;d|j        v r2| j        rt          |          | j        k    rd| _        dg| j        g}}n#d| _        | j                                        \  }}t#          | j        t$                    rd t'          | j                  D             }nd gt          |          z  }| j        }	d }
|D ](}| j         |
|          d |	         xx         dz  cc<   )i }t-          |||          D ]\  }}}|                     ||||          }|!t#          |t0                    s|f}|||<   t#          |t2                    r7| xj        t          |j                                                  dz
  z  c_        |st;          d| j        j        z            |S )	Nr`  Tr@   Fc                 ,    g | ]}t          |          S r@   r5   )rD   layers     rH   r   z7GenericOverlayPlot._create_subplots.<locals>.<listcomp>  s-     ; ; ;%.u55 ; ; ;rJ   c                 H    | j         j        | j        j        | j        j        fS rc   rT  r   rc  r   r"  rd   s    rH   rf   z5GenericOverlayPlot._create_subplots.<locals>.<lambda>      afoqv|QV\J rJ   r,   z6%s backend could not plot any Elements in the Overlay.)r   r  rb  r`  rT  rc  r   rQ   rO   r   r%  rq   r.  r%  rJ  legend_limit_split_overlaysrr   r    r:   style_groupingr;  r   _create_subplotr   r   r>  rz   r   r   )rG   r   r  r`  rO   batchedplotr   vmapsdmap_streamsrp  group_fnr  rz   r   vmapr   r@  s                    rH   r?  z#GenericOverlayPlot._create_subplots  s\   ?49--,D4	#7#79#D 	Km+G.155din6IJJK 	6 	6	[5N(N(N! )O%(]]T5F%F%FDL$%DD DL)3355KD%di,, 	,; ;.ty99; ; ;LL !6#d))+L $JJ 	8 	8AXXa[[&1222a72222$'e\$B$B 	A 	A S$**3gvFFGc5))7#3#HSM'#566 AG$4$9$9$;$; < <q @@ 	K !248M4I!J K K KrJ   c                     t           j         j        j                 }t	          j         j                  } j        j        t          k    rdnd}d }d|i}	 j        j        t          k    r"|j        j	        f|z   }
 j
        r
 j
        |	d<   nUt          |t                    s|f} ||          |z   }
t          t           j        j        j        |                    |	d<    j        rt          |j        j                  }d}nBt          |j                  }|
|vr|                    |
           |                    |
          }|                    |d           }|? j                            d                    |j	         j        j                             d S  j        }|
d |         } j        |z    j        z   } j        |         }| j        |
<    j        |xx         dz  cc<    j        |         }t          |t<                    sgt?          |t@                    rR j        |	d<    j!        |	d	<   tE          d
 |D                       s$ j                            d|j        z             d S ne j        r^d|j#        v rU j        $                                fd j%        D             } j        |	d<    j&        |	d<   |	'                    |           tQ          |           j)        k    rd|	d	<    *                    |j        d          +                    |          } fd j,        -                                D             }t          |	fi d|d j.        d j/        d j0        d j1        d|d j2        d|d j3        d j4        d|d j        d j5        d j6        d j7        d j8        d |d! j9        |} ||fi |S )"Nr,   r   c                 H    | j         j        | j        j        | j        j        fS rc   rV  rd   s    rH   rf   z4GenericOverlayPlot._create_subplot.<locals>.<lambda>  rW  rJ   r}  r~  r   z4No plotting class for {} type and {} backend found. r<  r%  c              3   4   K   | ]}t          |          V  d S rc   )rJ  )rD   rM  s     rH   r   z5GenericOverlayPlot._create_subplot.<locals>.<genexpr>7  s(      33es5zz333333rJ   z/%s is empty and will be skipped during plottingr`  c                 *    i | ]}|v ||         S r@   r@   )rD   r,  
param_valss     rH   rI   z6GenericOverlayPlot._create_subplot.<locals>.<dictcomp>=  s3     / / /#:-- jo---rJ   Fr  c                 .    i | ]\  }}|j         v ||S r@   )_passed_handlesrC   s      rH   rI   z6GenericOverlayPlot._create_subplot.<locals>.<dictcomp>E  s6     8 8 841a$"666 Q666rJ   r|  r  r   r   r?  r   rE  rB  ry  r   rQ   r=  re  r2  r{  ra  rZ   ):r   r%  rQ   rO   r   r  rb  rT  r   r   r~  rr   r   r   r   rc  r  r`  rY  r  rq   rB   rK  rq  rZ  ra  r>  r<  r=  r;  r   r  r   r%  r   r.  r{   r  r}  r   rJ  rX  r   r  rj   rK   r  r   r   r?  rE  rB  ry  r=  re  r2  r{  rZ   )rG   r   r   r   r   r%  r  overlay_typer_  r  	style_keyvtypeoidxplottyperp  	group_keyra  r|  group_length	propagater  passed_handlesplotoptsre  s   `                      @rH   r[  z"GenericOverlayPlot._create_subplot  s   >$-"78?49-- INg55qq1JJL)9>W$$*,s2I  9'+'8^$c5))7#3 +I#'DIN,@#(F(F#G#GD < 	-''EDDNNE((	***>>),,D<<t,,J &1FGGI I I 4 $gvg&	t#dl2))4.: +9%%%*%%%'	2(L11 	#jK]6^6^ 	#$($6D!"&"2D33s33333 
"" $57:x$@ A A At \ 	#i8+AAA**,,J/ / / /9P / / /I"lDO#}DKK	"""x==4,,,"'D##CHg66AA,OO8 8 8 84<+=+=+?+? 8 8 8 
I 
I 
I<< 
I$($4$4
I#'??
I9=
I +/*@*@
I  &v	
I 37//	
I
 $e
I
 .2\\
I "&
I 9@
I "&
I :>
I (,':':
I $(??
I ?Cnn
I  &v
I -1II
I 
I x((x(((rJ   c                 b    d}t          |          |sjt           |          \  }}}|M|sK fd j        D             }	d |	D             }	|	r'|	d         d         }                    |          \  }
}hd}|j|(|                                        |                    }|||fS )NFc           	      6    g | ]}t          |          S r@   )r0   )rD   rE   r  rG   r@  
temp_itemss     rH   r   z5GenericOverlayPlot._match_subplot.<locals>.<listcomp>\  s9     % % % 'tWa*MM% % %rJ   c                 "    g | ]}|d          
|S )r  r@   )rD   r  s     rH   r   z5GenericOverlayPlot._match_subplot.<locals>.<listcomp>`  s!    $G$G$G12$GQ$G$G$GrJ   r   T)rA  r0   rz   ry   r  )rG   r   r@  rK   r  foundidxrV  exactexact_matchesr   r^  rt  s   ` ` `       @rH   _match_subplotz!GenericOverlayPlot._match_subplotU  s   %[[
 	-dGS':VVCu 	!% % % % % % %!%% % %M %H$G$G$G$GM$ !+A.q1 *s 3 32 E  	 ?++jnnS1122CD%rJ   c                    | j         }d }|D ]\  }}| j                            ||fg          }	| j         ||	          d|         xx         dz  cc<   |                     ||	g |          }
|
c| j        |
_        | j        r| j        |
_        |
| j        |<    |
j        |fi | |
	                    |||           | j
                            |
           dS )z
        Handles the creation of new subplots when a DynamicMap returns
        a changing set of elements in an Overlay.
        c                 H    | j         j        | j        j        | j        j        fS rc   rV  rd   s    rH   rf   z=GenericOverlayPlot._create_dynamic_subplots.<locals>.<lambda>p  rW  rJ   Nr,   )r  )rZ  rb  cloner;  r[  rm   r   rz   r   rL  r@  rY  )rG   r   rK   r   init_kwargsrp  r_  rE   r   r`  r@  s              rH   _create_dynamic_subplotsz+GenericOverlayPlot._create_dynamic_subplotsj  s   
 $JJ 	2 	2FAs9??S#J<00DXXd^^GVG4555:555**1dB??G#}Gy )#y&DM!#G#F::k:::  fc :::!((1111	2 	2rJ   c                 P   || j         v r| j         |         }n;|d| j                 }| j        |xx         dz  cc<   | j        |         }|| j         |<   ||_        |j        rEt          j        |d                   }t          |j        |          }t          |          |_        dS dS )z
        Updates existing subplots when the subplot has been assigned
        to plot an element that is not an exact match to the object
        it was initially assigned.
        Nr,   r  )	r=  rZ  r<  r|  r~  r   
wrap_tupler   r   )rG   r@  rV  r|  rm  odim_keynew_dimss          rH   _update_subplotz"GenericOverlayPlot._update_subplot  s     4+++3D9LL1d112Iy)))Q.)))-i8L-9D$T*+ 	2tBx00H7/::H#'>>G   	2 	2rJ   c                 H   |dk    rg g g g d}n|g i}|                                 }| j        r`| j        rYt          t	          | j                                                            fd|j                                        D             }n| j                                         }|D ]\  }d}	
|j                            |d          }
t          | j
        t                    r,|
*|D ]#\  }}
t          |
j
        j                  rd}	 n$|	sd}
|
j        su|r                    |
|          st          |
t                    r|}n|rt!          j        |
|          ni }|D ]5}                    |
||          }||                             |           6|S )zN
        Iterates over all subplots and collects the extents of each.
        r  )r  r  r  r  c                     g | ]}|fS r@   r@   )rD   rE   r@  s     rH   r   z;GenericOverlayPlot._get_subplot_extents.<locals>.<listcomp>  s    BBBGBBBrJ   FNT)r  )rK   r`  rz   r  r  r{   r  r   rq   rr   rb  r    rT  r  r  r   r   
match_specr  rY  )rG   r  r   r  r  r  rK   rz   r   rv  rT  r   	sp_rangesrtextentr@  s                  @rH   _get_subplot_extentsz'GenericOverlayPlot._get_subplot_extents  s    ##"$b"bIIGG!2&G< 	-DM 	-4 4 4 6 67788GBBBBgl.?.?.A.ABBBHH}**,,H$ 	+ 	+LCEL$$S$//E$)Z00 !U] %  HAu!%):;;  $  ! E}G$8} !<!<UI!N!N %!122 M"		>DLDOE6:::"	 + + ,,UI",MM""6****+ rJ   r  c           	      
  " |                      ||||          }t          | j        t                    o
| j        dk    ""fd|                                D             }|dk    r||         S t          |d                   dk    r.|d         \  }}	}
}}}|d         \  }}}}}}|d         \  }}}}}}n?|d         \  }}	}}|d         \  }}}}|d         \  }}}}t          j        t          j        }}
d t          | j	                  D             \  }}}t          |||          \  }}t          |	||          \  }	}t          |
||          \  }
}|                     |||	|
|||f          \  }}}t          j        ||||f||f|| j                  \  }}t          j        |	|||f||f|| j                  \  }	}t          |d                   dk    r.t          j        |
|||f||f|| j                  \  }
}||	|
|||f} n||	||f} t          j        | |d	         g"          }!t          | j        t                    r| j        dk    r
|!\  }}	}
}}}n|!\  }}	}}t          j        ||| j        d
          \  }}d| j        v r| j        st          j        |	|| j        d
          \  }	}t          | j        t                    r<| j        dk    r1t          j        |
|t-          | dd
          d
          \  }
}||	|
|||fS ||	||fS )Nr1  c                 B    i | ]\  }}|t          j        |          S r@   )r   r  )rD   rE   r  zranges      rH   rI   z2GenericOverlayPlot.get_extents.<locals>.<dictcomp>  s,    XXXuq"1d&r622XXXrJ   r  r  r  r  r  c              3       K   | ]	}|d z  V  
dS r  r@   r  s     rH   r   z1GenericOverlayPlot.get_extents.<locals>.<genexpr>  s&      QQqtQQQQQQrJ   r  r   r3  r  )r  rr   r2  r  rK   rJ  r  r  r1   r  r3   r  r   r  r  r  r  r  r  rB   r3  r  r   )#rG   r  r   r  r  r   subplot_extentsr  r  r  r  r  r  r  sx0sy0sz0sx1sy1sz1hx0hy0hz0hx1hy1hz1r  r  r  r  r  r  paddedr  r  s#                                     @rH   r  zGenericOverlayPlot.get_extents  sp   33GVZQZ[[DOS11Mdo6MXXXX@U@U@W@WXXX##:&& wv1$$%,V_"BBB+26?(Cc3S+26?(Cc3SS$V_NBB!(Cc3!(Cc3VRVB RQ-=d>O-P-PQQQue!"b%00B!"b%00B!"b%00B  ++Gb"b"b"5MNNdD%b"sCj3*dDIVVB%b"sCj3*dDIVVBwv1$$)"b3*sCj$PTPYZZFB"b"b"-FF"b"%F #VWY-?$@&IIdos++ 	&40G0G%-"BBB%NBB %b"diFFBdj((dl()"b$)\JJFBdos++ 	,40G0G)"b'$2U2UWcddFBBB++BBrJ   )NTNNr  rc   )r  N)r   r   r   r   rB   rD  r`  r+  rX  r%  rZ  rg  r  rM   r:  r?  r[  rz  r  r  r  r  r   r   s   @rH   r   r     sz         emD /J K K KG !5= 2B C C CL  %- 30 1 1 1K #U]1 3I J J JN O FEE0 0 0 0 0 08   0( ( (TG) G) G)T     *2 2 2*2 2 2.) ) ) )V1  1  1  1  1  1  1  1 rJ   r   c                   4     e Zd Zd fd	Zd Zd Zd	dZ xZS )
r   Nc                    d|vrt          j        |          |d<   |d u | _        | j        rt          j        |          \  }}t	          |          \  }}|rt          |||d                    || _         t                      j        d|||d| |	                    d t          g          }t          d |D                       | _        |                                  d S )NrB  r   )r   rC  r   c                      t          |           S rc   rS  rd   s    rH   rf   z/GenericCompositePlot.__init__.<locals>.<lambda>  s    3Ea3H3H rJ   c                     h | ]	}|D ]}|
S r@   r@   )rD   r   r   s      rH   r  z0GenericCompositePlot.__init__.<locals>.<setcomp>  s%    NNN7gNNQNNNNrJ   r@   )r   rB  rk   unique_dimkeysr2   r8   layoutrL   rM   rg   r    rA  r   _link_dimensioned_streams)	rG   r  r   r   r[   rC  r  nested_streamsr\   s	           rH   rM   zGenericCompositePlot.__init__  s   F"" ) 1& 9 9F9> 	@(7??J-f55 	> T!W=== 	:dG$.	: 	:28	: 	: 	:)H)H*47 7NNnNNNOO&&(((((rJ   c                     dS )zo
        Should perform any linking required to update titles when dimensioned
        streams change.
        Nr@   r`   s    rH   r  z.GenericCompositePlot._link_dimensioned_streams
  rQ  rJ   c                    | j         du }| j                            d          }|| j         k    r| j        s| j        S || _         t          t          d | j        D             |                    }| j                                        D ]\  }}t          |||          }||||<   t          | dd           || _        |S )z\
        Creates a clone of the Layout with the nth-frame for each
        Element.
        NF)shared_datac                     g | ]	}|j         
S r@   r  r  s     rH   r   z3GenericCompositePlot._get_frame.<locals>.<listcomp>  r  rJ   rR   )r   r  r}  rR   rE  r   r   r   rK   r4   r;   )rG   r   r  layout_framer  r  r?  rM  s           rH   rP  zGenericCompositePlot._get_frame  s    
 !T){((U(;;$"""4;"%%"Ds<<DO<<<cBBCC+++-- 	+ 	+JD$)$@@E %*T"h...)rJ   Tr_  c                    |r|                      |d|          nd}| j        }t          | j                  j        }t	          j        |j        |k    r|j        nd          }t	          j        |j                  }||||fS )Nr  ra  )rn  r  rT  r   r   rk  r   r"  )	rG   r   r   rl  rt  r  rs  r   r"  s	            rH   rp  z-GenericCompositePlot._format_title_components'  s    <FND%%c1i888B	%%.	%fli6O6OfllUWXX%fl33ui33rJ   r   rA  )r   r   r   rM   r  rP  rp  r   r   s   @rH   r   r     so        ) ) ) ) ) )&    .4 4 4 4 4 4 4 4rJ   r   c                   F     e Zd ZdZ ej        dd          Z fdZ xZS )GenericLayoutPlotz
    A GenericLayoutPlot accepts either a Layout or a NdLayout and
    displays the elements in a cartesian grid in scanline order.
    Fz
        Whether to transpose the layout when plotting. Switches
        from row-based left-to-right and top-to-bottom scanline order
        to column-based top-to-bottom and left-to-right order.r+  c                    t          |t          t          f          st          d          t	          |                                          dk    rt          d           t                      j        |fi | i | _	        | j
        r|j        d d d         n|j        \  | _        | _        t          t          t!          | j                  t!          | j                                      | _        d S )Nz.GenericLayoutPlot only accepts Layout objects.r   F)warnr  )rr   r   r   rU  rJ  r{   r   rL   rM   rz   	transposeshaperowscolsrA  r   rj  coords)rG   r  r[   r\   s      rH   rM   zGenericLayoutPlot.__init__;  s    &8V"455 	OMNNNv}}1$$U++++**6***59^Uv|DDbD11	4975#3#3#(#3#35 5 6 6rJ   )	r   r   r   r   rB   rD  r  rM   r   r   s   @rH   r  r  0  sg         
 e 2B C C CI

6 
6 
6 
6 
6 
6 
6 
6 
6rJ   r  c                   4    e Zd ZdZddgidddgidg didZdS )rs   a  
    AdjointLayoutPlot allows placing up to three Views in a number of
    predefined and fixed layouts, which are defined by the layout_dict
    class attribute. This allows placing subviews next to a main plot
    in either a 'top' or 'right' position.
    	positionsmainro  )r  ro  rl  )SingleDualTripleN)r   r   r   r   layout_dictr@   rJ   rH   rs   rs   H  sN          *F84)FG+<=)+C+C+CDF FKKKrJ   rs   )[r   r   r  astr   collectionsr   r   	functoolsr   	itertoolsr   r   numpyr  rB   panel.configr	   panel.io.documentr
   panel.io.notebookr   panel.io.stater   pyviz_commsr   corer   r   	core.datar   r   core.elementr   r   core.layoutr   r   r   core.optionsr   r   r   r   core.overlayr   r   r   core.spacesr    r!   	core.utilr"   r#   r  r$   r%   	selectionr&   r   r'   r(   r)   r*   util.transformr+   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   Parameterizedr=   r   r(  rH  r   r   r   r  rs   r@   rJ   rH   <module>r     s   
         , , , , , , , ,       & & & & & & & &            & & & & & & " " " " " "             # # # # # # " " " " " " " " 1 1 1 1 1 1 1 1 - - - - - - - - 1 1 1 1 1 1 1 1 1 1 K K K K K K K K K K K K ? ? ? ? ? ? ? ? ? ? - - - - - - - - 3 3 3 3 3 3 3 3 " " " " " " " " , , , , , , 5 5 5 5 5 5 5 5 5 5 5 5                                             &l7 l7 l7 l7 l75 l7 l7 l7`D! D! D! D! D! D! D! D!PX	 X	 X	 X	 X	d X	 X	 X	v0 0 0 0 0 0 0 0hR
 R
 R
 R
 R
 R
 R
 R
jb  b  b  b  b + b  b  b J84 84 84 84 84? 84 84 84v6 6 6 6 6, 6 6 60
F 
F 
F 
F 
Ft 
F 
F 
F 
F 
FrJ   