
    Le{                        d dl Z d dlZd dlZd dlmZ d dlmZ d dl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mZmZmZmZmZmZ dd	lmZmZ dd
lmZm Z  ddl!m"Z" ddl#m$Z$ ddl%m&Z&m'Z' ddlm(Z(m)Z)m*Z* ddl%m+Z+m,Z, ddlm-Z-m.Z.m/Z/m0Z0  G d de&e+          Z1 G d de1          Z2 G d de1          Z3 G d de3e'          Z4dS )    N)FunctionType)ticker)date2num)	AxesImage)Version   )CompositeOverlayDataset
DynamicMapElement	Element3D	NdOverlayutil)Keywordsabbreviated_exception)GraphPath)Stream)dim   )GenericElementPlotGenericOverlayPlot)color_intervalsdim_range_keyprocess_cmap   )MPLPlotmpl_rc_context)EqHistNormalizempl_versionvalidatewrap_formatterc                       e Z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gd          Z ej        dd          Z ej        deej        efd          Z ej        deej        efd          Z ej        deej        efd          Z ej        dd          Z ej        dd          Z ej        ddd          Z ej        dd          Zg Zi Zg dZdZ fdZ 	 	 d/ fd	Z! fdZ"d Z#d Z$d Z%d0d Z&d! Z'd" Z(d# Z)d$ Z*d% Z+d& Z,d1d'Z-e.d2d(            Z/d) Z0e.d3d*            Z1d+ Z2d, Z3d- Z4d. Z5 xZ6S )4ElementPlotTz'
        Whether to apply custom ticks.defaultdocsquarea(  
        The aspect ratio mode of the plot. By default, a plot may
        select its own appropriate aspect ratio but sometimes it may
        be necessary to force a square aspect ratio (e.g. to display
        the plot as an element of a grid). The modes 'auto' and
        'equal' correspond to the axis modes of the same name in
        matplotlib, a numeric value specifying the ratio between plot
        width and height may also be passed. To control the aspect
        ratio between the axis scales use the data_aspect option
        instead.Nz\
        Defines the aspect of the axis scaling, i.e. the ratio of
        y-unit to x-unit.Fz+
        Whether to invert the plot z-axis.xyz0
        Whether to plot the 'x' and 'y' labels.zB
         Whether to apply log scaling to the y-axis of the Chart.z.
        Formatter for ticks along the x-axis.r&   class_r'   z.
        Formatter for ticks along the y-axis.z.
        Formatter for ticks along the z-axis.z'
        Whether to display the z-axis.zl
        An explicit override of the z-axis label, if set takes precedence
        over the dimension label.r   )r   ih  z&
        Rotation angle of the zticks.)r&   boundsr'   a  
        Ticks along z-axis specified as an integer, explicit list of
        tick locations, list of tuples containing the locations and
        labels or a matplotlib tick locator object. If set to None
        default matplotlib ticking behavior is applied.)markeralphacmapanglevisiblec                     t                      j        |fi | | j        j        }t	          |t
                    r|                                d         }t	          |t                    rd| _        | j	        D ]F}	  || |           # t          $ r*}| j                            d|d|            Y d }~?d }~ww xY wd S )Nr   3dzPlotting hook z could not be applied:

 )super__init__hmaplast
isinstancer	   valuesr   
projectioninitial_hooks	Exceptionparamwarning)selfelementparamscheckhooke	__class__s         >lib/python3.11/site-packages/holoviews/plotting/mpl/element.pyr6   zElementPlot.__init__f   s   ++F+++	e-.. 	&LLNN1%EeY'' 	#"DO& 	8 	8D8T7#### 8 8 8
"" $7D $7 $734$7 $7 8 8 8 8 8 8 8 88	8 	8s   =B


B> B99B>c                    ||                      |          }|| _        |sr|rp| j        si|                    d t          g          }|rJ|d         }t          |t                    r|j                                        n|                                }| j	        d         }| j        r&t          | j                                                  ng }| j        dk    r|| j        rMt          t          d          k    r|                    | j                   n|                    | j                   |                     |          }| j        rW|U|                     d          }d| j	        v r!| j	        d                             |           n |j        |fi || j	        d<   |                     |           | t1          d | g|z   D                       s|r|                     |||	|
|           ns| j        |                    | j                   | j        |                    | j                   | j        *t?          |d          r|                     | j                   |s|!                                }|r0|"                    | j#                   | j	        d	xx         |gz  cc<   |j$        %                    | j&                   |j'        %                    | j&                   | j(        r|)                    d
           | j*        r|+                    d
           t          | j,        tZ                    r| j,        dk    s8| .                    |d| j$                   | .                    |d| j'                   | j/        r| 0                    |||||           | 1                    ||||           | j2        -| j,        dk    r"| j3        s| 4                    || j2                   |s| j5        s| 6                    |           | 7                    |           tq                      9                    |          S )a*  
        Applies all the axis settings before the axis or figure is returned.
        Only plots with zorder 0 get to apply their settings.

        When the number of the frame is supplied as n, this method looks
        up and computes the appropriate title, axis labels and axis bounds.
        Nc                     | S N )r)   s    rG   <lambda>z,ElementPlot._finalize_axis.<locals>.<lambda>   s    A     r   axisz1.5.9titlec              3   &   K   | ]}|j          V  d S rJ   )	_has_axes).0sps     rG   	<genexpr>z-ElementPlot._finalize_axis.<locals>.<genexpr>   s'      .\.\B2</?.\.\.\.\.\.\rM   
set_zlabelbbox_extra_artistslogr4   r)   r*   polar):
_get_framecurrent_framesubplotstraverser   r9   r   nodes
dimensionshandleslistr:   zorderbgcolorr    r   set_axis_bgcolorset_facecolor_format_title
show_title	_fontsizeset_text	set_title_subplot_labelany_set_labelsxlabel
set_xlabelylabel
set_ylabelzlabelhasattrrU   
get_legendset_visibleshow_legendxaxisgrid	show_gridyaxislogx
set_xscalelogy
set_yscaler;   str_set_axis_positionapply_ticks_finalize_ticks_set_axis_limitsaspectadjoined_set_aspectdrawn_finalize_artist_execute_hooksr5   _finalize_axis)r@   keyrA   rO   r^   rangesxticksytickszticksrm   ro   rq   elrN   r[   fontsizelegendrF   s                    rG   r   zElementPlot._finalize_axisu   sZ    ?ooc**G$ 	ag 	adm 	a!!++y99B aU6@U6K6K`RX00222QSQ^Q^Q`Q`
|F#37=H4,,..///b;!| 5''"2"222))$,7777&&t|444 &&s++E N5#4>>'22dl**L)2259999,:DN5,M,MH,M,MDL) %%% "3.\.\4&S[J[.\.\.\+\+\" 5$$T:vvvNNNN{.444{.444{.743N3N.444 4!__..F G**4+;<<<%9:::vhF:::JOODN333JOODN333 9 +OOE***9 +OOE***"4?C88 CT_PT=T=T++D#tzBBB++D#tzBBB # S((z666RRR %%dGXvFFF {&4?g+E+Edm+E  t{333 	+
 	+!!'***G$$$ww%%c***rM   c                 r    t                                          |           |                                  d S rJ   )r5   r   _update_backend_opts)r@   rA   rF   s     rG   r   zElementPlot._execute_hooks   s3    w'''!!#####rM   c                 (   |rt          |          nd}|r|d         nd}|dk    r|d         nd}|r!|                     |j        || j                   |r!|                     |j        || j                   t          | j        t                    rE| j        dk    r:|dk    r|d         nd}	|	s| j	        !|                     |j
        |	| j	                   |r|n| j        }|                     |j        || j        | j                   |r|n| j        }|                     |j        || j        | j                   t          | j        t                    r>| j        dk    r3|r|n| j        }|                     |j
        || j        | j                   d}
|j        |j        g}t+          |d          r|
d	z  }
|                    |j
                   t/          |
|          D ]/\  }}|                     | d
dd          }|r |j        di | 0dS )z
        Finalizes the ticks on the axes based on the supplied ticks
        and Elements. Sets the axes position as well as tick positions,
        labels and fontsize.
        r   Nr   r4   r   )rW   rotationxyzaxiszticks	labelsizeFcommonrK   )len_set_axis_formatterrv   
xformatterry   
yformatterr9   r;   r~   
zformatterr   r   _set_axis_ticksrz   	xrotationr   r|   	yrotationr   logz	zrotationrr   appendziprg   set_tick_params)r@   rN   r^   r   r   r   ndimsxdimydimzdimaxes_str	axes_listaxax_objtick_fontsizes                  rG   r   zElementPlot._finalize_ticks   ss    $.4J1 %/z!}}4 %		z!}}t  	H$$TZtGGG 	H$$TZtGGGdos++ 	L40G0G$)AII:a==4D Lt2((T4?KKK!2t{TZTY&*n 	 	6 	6 	6 "2t{TZTY&*n 	 	6 	6 	6 dos++ 	:40G0G%6VV4;F  V*.. ! : : : Z,	4!! 	)OHTZ(((h	22 	F 	FJB NNb<<<5NQQME4f4EE}EEE	F 	FrM   c                    | j         d         }ddddd}| j                                        D ]"\  }}|                     |||          }| |\  }}|                    d          sd| }t          |t                    s|g}n|}	 |D ]}	 t          |	|          |           z# t          $ r}
d t          |d                   D             }t          |          }t          |                    |                    }| j                            d	|
 d
|dt          |d                   j        d|d|
           Y d }
~
d }
~
ww xY wd S )NfigrN   cbar)figureaxesr   colorbarset_c                 <    g | ]}|                     d           |S )r   
startswith)rR   attrs     rG   
<listcomp>z4ElementPlot._update_backend_opts.<locals>.<listcomp>  s*     \ \ \$DOOTZD[D[ \ \ \ \rM   r   )r:   zEncountered error: z, or could not find z method on z& model. Ensure the custom option spec zX you provided references a valid method on the specified model. Similar options include )r_   backend_optsitems_parse_backend_optr   r9   r`   getattrAttributeErrordirr   sortedfuzzy_matchr>   r?   type__name__)r@   plotmodel_accessor_aliasesoptval
parsed_optmodelattr_accessormodelsmexcvalid_optionskwsmatchess                 rG   r   z ElementPlot._update_backend_opts   s   |E" 	"
 "
 )//11 	 	HC00T13 3J!#- E= ++F33 7 6} 6 6eT**    3 3A-GA}--c22223! 	 	 	 \ \#fQi.. \ \ \m444 !?!?@@
""`# ` `$` `37q	??3K` `<?` ` U\` `       		)	 	s   	B((
E2BE

Ec                     dS )zc
        Allows extending the _finalize_axis method with Element
        specific options.
        NrK   )r@   rA   s     rG   r   zElementPlot._finalize_artist%  s      rM   c                    |                      ||||          \  }}}| j        r||}}|r1| j        r*d| j        v r! |j        |fi |                     d           |r1| j        r*d| j        v r! |j        |fi |                     d           |r3| j        r.d| j        v r' |j	        |fi |                     d           dS dS dS dS )z
        Sets the labels of the axes using the supplied list of dimensions.
        Optionally explicit labels may be supplied to override the dimension
        label.
        r)   rm   r*   ro   r   rq   N)
_get_axis_labelsinvert_axesrv   labelledrn   rg   ry   rp   r   rU   )r@   r   r^   rm   ro   rq   s         rG   rl   zElementPlot._set_labels+  s,    "&!6!6z66SY!Z!Z 	,#VFF 	@dj 	@SDM%9%9DOF??dnnX&>&>??? 	@dj 	@SDM%9%9DOF??dnnX&>&>??? 	@dj 	@SDM%9%9DOF??dnnX&>&>?????	@ 	@ 	@ 	@%9%9rM   c                     t          |t                    r|d         }||n/|j        r|j        }n |j        |j        v r|j        |j                 }|r$|                    t          |                     dS dS )zB
        Set axis formatter based on dimension formatter.
        r   N)r9   r`   value_formatr   type_formattersset_major_formatterr"   )r@   rN   r   	formatters       rG   r   zElementPlot._set_axis_formatter<  s     c4  .A# CK 	6(IIX,,,+CH5I 	@$$^I%>%>?????	@ 	@rM   c                     t          | j        t          t          f          r| j        S | j        dk    rdS | j        dk    r||z  S dS )z7
        Computes the aspect ratio of the plot
        r(   r   equal)r9   r   intfloat)r@   xspanyspans      rG   
get_aspectzElementPlot.get_aspectK  sR     dkC<00 	;[H$$1[G##;qrM   c                    t          | j        t                    r| j        dk    rdS t          |t                    r|dk    s| j        r
| j        p|}n|                                |                                c\  }}\  }}| j        r)t          j        |          t          j        |          z
  n||z
  }| j	        r)t          j        |          t          j        |          z
  n||z
  }	t          t          |          d          }t          t          |	          d          }	d|	|z  z  }|dk    r||z  }|                    |           dS )zI
        Set the aspect on the axes based on the aspect setting.
        r4   Nr(   gKH9      ?)r9   r;   r~   data_aspectget_xlimget_ylimrz   nprW   r|   maxabs
set_aspect)
r@   r   r   
data_ratiox0x1y0y1xsizeysizes
             rG   r   zElementPlot._set_aspectX  s<    dos++ 	40G0GF$$ 	/8);); *<)3VJJ!%$--//HRhr2/3yCBF2JJ++beE/3yCBF2JJ++beEE

E**EE

E**EU5[)J!!'.

#####rM   c                 (   |                      ||          }|r| j        r|                    dd           dS d }d |D             }d |D             }t          | j        t
                    r| j        dk    st          |          dk    rv|\  }}	}
}}}| j        st          d	 |D                       r||
}}
|
|k    rB ||
          r|	                    |

            ||          r|	                    |           nEt          | j        t
                    r$| j        dk    r|\  }}	}}d}dt          j        z  }n|\  }}	}}| j        r|	|||f\  }}	}}| j        pt          d |D                       }|                     ||| j        |dd          \  }}| j        pt          d |D                       }|                     |	|| j        |dd          \  }}|r |j        di | |r |j        di | |                    ||           dS )zK
        Compute extents for current view and apply as axis limits
        T)scalexscaleyNc                 T    t          j        |           ot          j        |            S rJ   r   	isnumericr   isnancs    rG   rL   z.ElementPlot._set_axis_limits.<locals>.<lambda>x      dnQ//CO rM   c                     g | ]>}t          |t          j                  st          j        |          r|nt          j        ?S rK   )r9   r   
datetime64isrealnan)rR   coords     rG   r   z0ElementPlot._set_axis_limits.<locals>.<listcomp>y  sA    qqq`e:eR];;[ry?O?O[%%UWU[qqqrM   c                     g | ]?}t          |t          j                  r!t          t	          j        |                    n|@S rK   )r9   r   r  r   r   
dt64_to_dt)rR   r   s     rG   r   z0ElementPlot._set_axis_limits.<locals>.<listcomp>z  sQ     # # # 3=Q2N2NU(4?1--...TU # # #rM   r4      c              3   $   K   | ]}|j         V  d S rJ   )invert_zaxisrR   ps     rG   rT   z/ElementPlot._set_axis_limits.<locals>.<genexpr>~  s$      'I'I1'I'I'I'I'I'IrM   )bottom)toprX   r   r   c              3   $   K   | ]}|j         V  d S rJ   )invert_xaxisr  s     rG   rT   z/ElementPlot._set_axis_limits.<locals>.<genexpr>  $      *L*La1>*L*L*L*L*L*LrM   leftrightc              3   $   K   | ]}|j         V  d S rJ   )invert_yaxisr  s     rG   rT   z/ElementPlot._set_axis_limits.<locals>.<genexpr>  r  rM   r  r  rK   )get_extentsoverlaidautoscale_viewr9   r;   r~   r   r
  rk   set_zlimr   pir   r  _compute_limitsrz   r  r|   set_xlimset_ylim)r@   rN   viewr[   r   extents	valid_limcoordslbzminrtzmax_invertxxlimr   invertyylimr   s                        rG   r   zElementPlot._set_axis_limitsn  s   
 ""400 	$- 	tD999FCC	qqipqqq# #!# # #t,, 	 D1H1HSQX\\]^M^M^%+"Aq$1d  (C'I'I'I'I'I$I$I (!4dt||9T?? /MMM...9T?? ,MMdM+++-- 	 $/W2L2LJAq!QABE	AAJAq!Q 	$Aq!JAq!Q#Ls*L*L8*L*L*L'L'L++Aq$)WfgVVf#Ls*L*L8*L*L*L'L'L,,Q49gxQVWWf 	"DM!!D!!! 	"DM!!D!!!6&99999rM   c                 r   d}i }d }	t          |t          j                  sI|rG||dk    r?|dk     rdndt          j        |          dz
  z  }| j                            d|z             |r||}}t          |t          j                  s||k    r$ |	|          r|||<   d} |	|          r|||<   d}||fS )	NTc                 T    t          j        |           ot          j        |            S rJ   r   r   s    rG   rL   z-ElementPlot._compute_limits.<locals>.<lambda>  r   rM   r   {Gz?
   r   zLogarithmic axis range encountered value less than or equal to zero, please supply explicit lower-bound to override default of %.3f.F)r9   r   datetime_typesr   log10r>   r?   cftime_types)
r@   lowhighrW   invertlow_keyhigh_keyscalelimsr   s
             rG   r  zElementPlot._compute_limits  s   CC	#t233 	B 	BPSWXPXPX++$$2q0@+ACJ;=@AB B B  	"T#Dc4,-- 	y~~  #Wy !%XU{rM   c                    ddgddgd|         }|dk    r|j         n|j        }|dv r;|                    d           |D ]"}|j        |                             d           #n|d	u r|d
         }d|v r*|                    g            |                    d           |dk    rE|                    d          d
         }|                    |           |                    |           | j	        sV| j
        sQ| j        dk    rH|r|dk    s
|d
         |v r|d         n|d
         }|j        |                             d           dS dS dS dS )a  
        Set the position and visibility of the xaxis or yaxis by
        supplying the axes object, the axis to set, i.e. 'x' or 'y'
        and an option to specify the position and visibility of the axis.
        The option may be None, 'bare' or positional, i.e. 'left' and
        'right' for the yaxis and 'top' and 'bottom' for the xaxis.
        May also combine positional and 'bare' into for example 'left-bare'.
        r  r  r  r  )r)   r*   r)   )NFFTr   bare -rX   r   N)rv   ry   rt   spinesset_ticklabelsset_label_textsplitset_ticks_positionset_label_positionr  
show_framer;   )r@   r   rN   option	positionsposs         rG   r   zElementPlot._set_axis_position  s    $U+672CDDTJ	!S[[tzzdj]""U###  4 4C ,,U33334 ~~"1##B'''##B'''c**1-''///''///} 	0T_ 	0G9S9S$* %&0@0@IaLTZDZDZ9Q<<!! K((/////	0 	0 	0 	09S9SrM   c                    t          |t          j                  rt          |          }t          |t          t          f          rQt          d |D                       r8|                    |d                    |                    |d                    nt          |t          j	                  r|
                    |           n||s|                    g            nt          |t                    rQ|r%t          j        |t          dd                    }nt          j        |          }|
                    |           not          |t          t          f          rSd}t          d |D                       rt          | \  }}|                    |           |r|                    |           |                                D ]}|                    |           dS )au  
        Allows setting the ticks for a particular axis either with
        a tuple of ticks, a tick locator object, an integer number
        of ticks, a list of tuples containing positions and labels
        or a list of positions. Also supports enabling log ticking
        if an integer number of ticks is supplied and setting a
        rotation for the ticks.
        c              3   @   K   | ]}t          |t                    V  d S rJ   )r9   r`   )rR   r"  s     rG   rT   z.ElementPlot._set_axis_ticks.<locals>.<genexpr>  s,      3W3WAJq$4G4G3W3W3W3W3W3WrM   r   r   Nr0  )numtickssubsc              3   @   K   | ]}t          |t                    V  d S rJ   r9   tuplerR   r&  s     rG   rT   z.ElementPlot._set_axis_ticks.<locals>.<genexpr>  s,      77A:a''777777rM   )r9   r   ndarrayr`   rO  all	set_ticksr@  r   Locatorset_major_locatorr   
LogLocatorrangeMaxNLocatorr   get_ticklabelsset_rotation)r@   rN   r   rW   r   locatorlabelsticks           rG   r   zElementPlot._set_axis_ticks  s    eRZ(( 	 KKEedE]++ 	,3W3WQV3W3W3W0W0W 	,NN58$$$a))))v~.. 	,""5))))uNN2s## 	, 4 +U16q> > > !,U33""7++++e}-- 	,F7777777 , #UvNN5!!! ,##F+++'')) 	( 	(Dh''''	( 	(rM   c                    t          | j        t                    o| j        }| j        | _        |s||                     |          }n||| _        || _        |+ | j        j	        di | 
                    |d          j         | j        d         }|dup| j        }|j                            |o| j                   |j                            |o| j                   |j                            t%          j        t)          |          dg                     | j                                        D ]2\  }}t-          |d          }	|dvr|	r|                    |du           3|dS |                     | j        ||          }t1          j        ||          }| j        j        }
| 
                    |d          }|
r|                    |
          n|| _        t;          | di           }| j        r|j        nd	}tA          d|!                    ||          | j"        d
| j        | j#                 }| $                    |||||          } | j%        |f||d|r|ni  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   rN   r   rt   )rN   r   stylelegend_labelsr=  )labelra   rA   r   rK   )&r9   r7   r   r  rZ   
prev_framerY   current_keyr>   updatelookup_optionsoptionsr_   rv   rt   ry   patch	set_alphar   minr   r   rr   compute_rangesr   
match_specr_  _max_cycles
max_cyclesr   ru   ra  dictgetra   cyclic_indexupdate_handlesr   )r@   r   r   rA   reusedrN   axes_visiblehnamehandlehideablern  r_  r\  ra  axis_kwargss                  rG   update_framezElementPlot.update_frame  s    DIz22Dt}- 	)'/ooc**GG "D!(DDJMM 3 3GV D D LMMM|F#d*;dm
|:
;;;
|:
;;;
RVS%6%6$:;;<<<!\//11 	8 	8ME6v}55HO+++""7$#6777?F$$TYV<<&11Z+
##GW555?JU%%j111U
33!%!19ri6::eU33DKii4:VZVgKhii))#tWfeLLC 	D 	D 	D.9A{{r	D 	D 	D 	D 	DrM   c                    |                      |||          \  }}}|                    dd           }t                      5  |                     |||          }	d d d            n# 1 swxY w Y   |rnd|	v rjt	          |	d         d          rT|	d                                         \  }
} |j        |
|d         fd|d         i| j        }|                    |           |	|fS )N
cat_legendartistlegend_elementsfactorsrO   )	get_datapopr   init_artistsrr   r}  r   _legend_opts
add_artist)r@   rA   r   r_  r   	plot_dataplot_kwargsrx  r   r_   legend_handlesr(  legs                rG   render_artistszElementPlot.render_artists#  sV   .2mmGVU.S.S+	;t44"$$ 	D 	D''I{CCG	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	h'))ggh6GIZ.[.[) ' 1 A A C CNA")NF9,= H H"(/H595FH HCMM###s    A$$A(+A(c                   	 | j         j        }| j        d         }t          | j         j                                                  d         }t          t          d | j         j        D             |                    	t          	fd| j
        D                       }|                     | j         ||          }|| _        || _        || _        t          j        ||          }t          dd| j        i| j        | j                 }| j        r
|j        |d<   |                     ||||          \  }}| j                            |           | j        }g | _        t3          j        |            | j        | j        d         f||d|S )	NrN   c              3   $   K   | ]}|j         V  d S rJ   namerR   ds     rG   rT   z.ElementPlot.initialize_plot.<locals>.<genexpr>4  s$      <<qAF<<<<<<rM   c              3   N   K   | ]}                     |j        d           V   d S rJ   )rp  r  )rR   r  dim_maps     rG   rT   z.ElementPlot.initialize_plot.<locals>.<genexpr>5  s3      GG!GKK--GGGGGGrM   ra   ra  rb  rK   )r7   r8   r_   r`   datakeysro  r   kdimsrO  r^   rk  current_rangesrZ   rd  r   rl  ra   r_  rq  ru   ra  r  re  _triggerr   triggerr   )
r@   r   rA   r   r   r_  r_   rx  r  r  s
            @rG   initialize_plotzElementPlot.initialize_plot/  s   ).\&!49>&&(())"-s<<DIO<<<cBBCCGGGGtGGGGG$$TYV<<$$&11IIDKI4:d6G+HII 	+$]E'N#227FE2NNG$$$-w"t"49R= 2'& 2 2%02 2 	2rM   c                    | j                             | j        rdnd          }t          ||          }d|v r,|                    dd           |                    dd           t          j                    5  t          j        dd            ||i |}ddd           n# 1 swxY w Y   d	t          |t                    rt          |          d
k    r|d         n|iS )z_
        Initializes the artist based on the plot method declared on
        the plot.
        batchedsinglenormvminNvmaxignorez)No data for colormapping provided via 'c'r|  r   r   )_plot_methodsrp  r  r   r  warningscatch_warningsfilterwarningsr9   r`   r   )r@   r   	plot_argsr  plot_methodplot_fnr|  s          rG   r  zElementPlot.init_artistsK  s2   
 (,,$,-TYYHUU"k**[  __VT***__VT***$&& 	8 	8#H.YZZZWi7;77F	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 z&$'?'? -Fq   !))&,. 	.s   7B!!B%(B%c                     |                                   |                     ||||          \  }}| j                            |           |S )z2
        Update the elements of the plot.
        )teardown_handlesr  r_   re  )r@   r   rN   rA   r   r_  r_   rx  s           rG   rr  zElementPlot.update_handles]  sP     	#227FE4PPG$$$rM   c                    t          |          }|                                D ]\  t          t                    rt	                    dk    r0|v st          |t
                    r|j        v rt                    nMt          fd| j	        D                       r-t          t          fd| j	        D                                 t          t                    sŉ                    |          sFj        | j	        vr8|                               | j                            d dd            j        | j	        v rbt!          d | j	                                        D             t#          | j	                            }                    |d          d	         }n`t'          |          t(          u r4t+          j        fd
|                                D                       }n                    |          }t+          j        |          sAt3          t5          j        |                    dk    rdvst	          d|          r|d	         }t+          j        |          sK| j        v rBt'          |          j        }t=          d d| d| j        j          dj         d d          tC          | dg           }fd|D             }|r|d	         nd }	|	dn|	dz   dz   dz   fv rt          |t4          j"                  rt	          d|          s|                               | #                    |||           |j$        j%        dv rtM                    }
|
v rd|
         v r|
         d         }nt5          j        |          }t5          j'        ||          }tC          | di           fd|D             }j        d|d|d<   dz   ||<   t#          |                                          D ]\  }dk    r|                    dd            tC          | dg           }fd|D             }|r|d	         nd }	|	dn|	dz   dk    stC          | d d          ot          fd!| j(        D                       }dz   dz   fv rt          |t4          j"                  r|)                    d"z             }|r%t	          d|          r|                    d"           |)                    d#z             }|r||r%t	          d|          r|                    d#           9d$k    rmt          |)                    d|)                    d                    t*          j*                  s,|                    dd            |                    dd            |S )%NTc              3   $   K   | ]
}|k    V  d S rJ   rK   rR   r  vs     rG   rT   z0ElementPlot._apply_transforms.<locals>.<genexpr>o  s'      99!A999999rM   c              3   (   K   | ]}|k    |V  d S rJ   rK   r  s     rG   rT   z0ElementPlot._apply_transforms.<locals>.<genexpr>p  s'       F FqA F FrM   z
Specified z dim transform z? could not be applied, as not all dimensions could be resolved.c                 $    i | ]\  }}|j         |S rK   r  r  s      rG   
<dictcomp>z1ElementPlot._apply_transforms.<locals>.<dictcomp>|  s     NNNDAqafaNNNrM   r   flatr   c                 @    g | ]}                     |d           S )Tr  )apply)rR   r   r   r  s     rG   r   z1ElementPlot._apply_transforms.<locals>.<listcomp>  sA     &A &A &A*, '(ggbdg&K&K &A &A &ArM   r   colorzMapping a dimension to the "z'" style option is not supported by the z element using the z backend. To map the "z" dimension to the zB use a groupby operation to overlay your data along the dimension._style_groupsc                 >    g | ]}                     |          |S rK   r   rR   sgks     rG   r   z1ElementPlot._apply_transforms.<locals>.<listcomp>  *    DDDR1<<3C3CDbDDDrM   r=  r(  r   OSUMr~  r`  c                 <    g | ]}                     ||          S rK   )rp  )rR   fr\  s     rG   r   z1ElementPlot._apply_transforms.<locals>.<listcomp>  s'    AAAAvzz!Q//AAArM   )rO   propr~  r{  c                 >    g | ]}                     |          |S rK   r   r  s     rG   r   z1ElementPlot._apply_transforms.<locals>.<listcomp>  r  rM   edgefilledc              3   H   K   | ]}|                     d z             V  dS )faceNr   )rR   oprefixs     rG   rT   z0ElementPlot._apply_transforms.<locals>.<genexpr>  s3      MMVF]33MMMMMMrM   	facecolor	edgecolor
facecolors)+ro  r   r9   r~   r!   r   r]   r   rk   overlay_dimsnextapplies	dimensionr  r>   r?   r
   r`   r  r   r   r   concatenaterB  isscalarr   r   unique_array_nonvectorized_stylesr   
ValueErrorrendererbackendr   arraylike_types_norm_kwargsdtypekindr   search_indices
style_optsrp  rQ  )r@   rA   r   r_  	new_styledsr   style_groupsgroupsgroup	range_keyr~  supports_fill
fill_style
line_styler  r\  r  r  s     `            @@@@rG   _apply_transformszElementPlot._apply_transformsg  s   KK	KKMM >	 >	DAq!S!! HAq>>T))'\\j%&@&@\Q'-EWEWAAA9999t'899999 HD F F F FD,= F F FFFGGAa%% ii(( Q[@Q-Q-Qa   
""H H H1 H H HI I I {d///NND4E4K4K4M4MNNN!$"3446 6ggbdg;;A>g$&&n &A &A &A &A &A07&A &A &A B B gggv..K$$ T->s-C-C)D)D)I)I!!Xgs%;%;!!f;s## NT-G(G(Gw--0  "M "M "M$+"M "M@D@U"M "M :;"M "M ,-	"M "M "M N N N #4"==LDDDD<DDDF!'1F1IITE =RReCiFfSj&.111jdFZ6[6[1 #.. 2a   !!'69afMMM9>V++ -a 0 0I F**yF9<M/M/M"("3I">"&"3C"8"8-c7;;C$T?B??FAAAAAAAG!"cg/ /Il+ 3JIaLL9??,,-- 	) 	)FAsCxxgt,,,"4"==LDDDD<DDDF!'1F1IITE =RReCiF 6!BWT8T%B%B NMMMMT_MMMMM  VCZ000ZTEY5Z5Z0&]]6++=>>
 /(7J"?"? /MM+...&]]6++=>>
 ! Z%; /(7J"?"? /MM+...l"":immGY]][^M_M_6`6`bdbl+m+m"gt,,,c4(((rM   c                 Z    d| j         v r!| j         d                                          dS dS )z
        If no custom update_handles method is supplied this method
        is called to tear down any previous handles before replacing
        them.
        r|  N)r_   remove)r@   s    rG   r  zElementPlot.teardown_handles  s8     t|##L"))+++++ $#rM   )
NNNNNNNNNN)NNN)Fr   NNrJ   )7r   
__module____qualname__r>   Booleanr   	Parameterr   Numberr   r
  Listr   r   ClassSelectorr~   r   	Formatterr   r   r   r   r   Stringrq   Integerr   r   r  r  r  rQ   r6   r   r   r   r   r   rl   r   r   r   r   r  r   r   r   ry  r  r  r  rr  r  r  __classcell__rF   s   @rG   r$   r$   !   s       %- 3* + + +K U_X 	4 	 	 	F %,t 2   K !5= 5. / / /L uz3* 33 4 4 4H EM% .E F F FD %$c6#3\B I12 2 2J %$c6#3\B I12 2 2J %$c6#3\B I12 2 2J EM$ -* + + +E U\$ -% & & &F a ?) * * *I U_T 0; < < <F J L LKK I8 8 8 8 8 bfRVU+ U+ U+ U+ U+ U+n$ $ $ $ $*F *F *FX' ' 'R  @ @ @ @"@ @ @
 
 
$ $ $,): ): ):X  ,0 0 0>!( !( !( !(H -D -D -D ^-D^
$ 
$ 
$ 2 2 2 ^26. . .$  c c cL, , , , , , ,rM   r$   c                       e Zd Z ej        dd          Z ej        ej        ej        fdd          Z	 ej
        deeefd	          Z ej
        deej        efd
	          Z ej        dd          Z ej        i d          Z ej
        deefd	          Z ej        dg dd          Z ej        i d          Z ej        dd          Z ej        dd          Z  ej        dd          Z! ej        g ddd          Z" ej        dd          Z# ej        dd          Z$i Z%dZ& fdZ'd  Z(d! Z)d%d"Z*d&d$Z+ xZ,S )'ColorbarPlotNzz
        An explicit override of the color bar label, if set takes precedence
        over the title key in colorbar_opts.r%   r   z
        User-specified colorbar axis range limits for the plot, as a
        tuple (low,high). If specified, takes precedence over data
        and dimension ranges.)r&   lengthr'   Fz
        Percentile value to compute colorscale robust to outliers. If
        True, uses 2nd and 98th percentile; otherwise uses the specified
        numerical percentile value.r+   z5
        Formatter for ticks along the colorbar axis.z$
        Whether to draw a colorbar.B
        Allows setting specific styling options for the colorbar.z
        Number of discrete colors to use when colormapping or a set of color
        intervals defining the range of values to map each color to.linear)r  rW   eq_histz?
        Color normalization to be applied during colormapping.)r&   objectsr'   a  
        Dictionary to specify colors for clipped values, allows
        setting color for NaN values and for values above and below
        the min and max value. The min, max or NaN color may specify
        an RGB(A) color as a color hex string of the form #FFFFFF or
        #FFFFFFFF or a length 3 or length 4 tuple specifying values in
        the range 0-1 or a named HTML color.r/  z2
        Padding between colorbar and other plots.a  
        Ticks along colorbar-axis specified as an integer, explicit
        list of tick locations, list of tuples containing the
        locations and labels or a matplotlib tick locator object. If
        set to None default matplotlib ticking behavior is
        applied.g?z=
        Width of the colorbar as a fraction of the main plot)neitherbothrj  r   zH
        If not 'neither', make pointed end(s) for out-of- range values.r  r&   r'   Ta  
        If ``cnorm='eq_hist`` and there are only a few discrete values,
        then ``rescale_discrete_levels=True`` decreases the lower
        limit of the autoranged span so that the values are rendering
        towards the (more visible) top of the palette, thus
        avoiding washout of the lower values.  Has no effect if
        ``cnorm!=`eq_hist``. Set this value to False if you need to
        match historical unscaled behavior, prior to HoloViews 1.14.4.z<
        Whether to make the colormap symmetric around zero.z#8b8b8bc                 :     t                      j        |i | d S rJ   )r5   r6   )r@   argskwargsrF   s      rG   r6   zColorbarPlot.__init__$  s%    $)&)))))rM   c                    t          j        | j        | j                                     dd                    dk    }dD ]0}|                     |d                              d          }| n1|j        r|r|j                            d           |                    ||           t          | j
        t          j                  r&|j        j                            | j
                   n| j
        d	k    r|                    g            nt          | j
        t"                    r9t          j        | j
                  }|j        j                            |           nt          | j
        t&                    rwt)          d
 | j
        D                       rt+          | j
         \  }}	nt+          fd| j
        D              \  }}	|                    |           |                    |	           dD ]L}
|                     |
d                              d          }||j                            |            d S Md S )Nr/   r   )clabelr\  Fr   r   r  )r   r   c              3   @   K   | ]}t          |t                    V  d S rJ   rN  rP  s     rG   rT   z,ColorbarPlot._adjust_cbar.<locals>.<genexpr>:  s,      AAA:a''AAAAAArM   c                 4    g | ]}| j         |          fS rK   pprint_value)rR   r&  r   s     rG   r   z-ColorbarPlot._adjust_cbar.<locals>.<listcomp>=  sB     &B &B &B,- ()*:#*:1*=*=&> &B &B &BrM   )cticksr   )r   )mathfloorr_  rq  rp  rg   solidsset_edgecolor	set_labelr9   
cbar_ticksr   rT  r   ry   rU  rS  r   rX  r`   rR  r   r@  tick_params)r@   r   ra  r   noalphalbr   r[  r   r\  tkticksizes      `        rG   _adjust_cbarzColorbarPlot._adjust_cbar'  s[   *TZ(9:>>wJJKKqP& 	 	Br%88<<ZHHI$ % K 	.G 	.K%%f---uy111dov~66 	(GM++DO<<<<_!!NN2-- 
	((99GGM++G4444.. 	(AAAAAAA C #T_ 5vv # &B &B &B &B15&B &B &B !CvNN5!!!'''% 	 	B~~b~77;;JGGH###h#777 $	 	rM   c                     | j         r>d | j                                        D             }|D ]}|                     ||           d S d S )Nc                 B    g | ]\  }}|                     d           |S )	color_dim)endswith)rR   r  hs      rG   r   z1ColorbarPlot._finalize_artist.<locals>.<listcomp>K  s-    RRR$!Q!**[:Q:QRARRRrM   )r   r_   r   _draw_colorbar)r@   rA   dimsr  s       rG   r   zColorbarPlot._finalize_artistI  si    = 	0RR$,"4"4"6"6RRRD 0 0##GQ////	0 	00 0rM   c                    || j         j        }| j                            dd           }| j        d         }| j        d         }t          j                            t          |          g d f          \  }}d |D             }	t          j        |          }
||sO|r|j	        
                                 |                                }|j        |j        |j        |j        f\  }}}}n|\  }}}}t!          |t"                    r|j        }|                    |          }| j        | j        }n(|r|j        }n|j        r|j        d         j        }n|d}| j        }| j        }|
d d         |	vrt3          |          }||z  }|                    ||z   |z   ||z   |dz  z   |z  z   |||g          } |j        |f||| j        d	| j        }|                     |j        j         || j!                   | "                    |||           || j        d
<   || j        d<   |j         #                                }| j        dxx         ||gz  cc<   |$                    |||
|f           tK          |          D ]=\  }\  }}}}||z  }|&                    ||z   |z   ||z   |dz  z   |z  z   |||g           >|||||fft          j        t          |          <   d S )Nr|  r   rN   c                 ,    g | ]\  }}}}|d d         S )Nr   rK   )rR   r(  specs      rG   r   z/ColorbarPlot._draw_colorbar.<locals>.<listcomp>W  s(    <<<maD!bqb<<<rM   r   r=  r   g333333?)caxr   extendr  r   rV   )'r7   r8   r_   rp  r  
_colorbarsidr   get_speccanvasdrawget_positionr   r   widthheightr9   r   r  get_dimensionr  pprint_labelvdimscbar_padding
cbar_widthr   add_axesr   cbar_extendcolorbar_optsr   r   ry   
cformatterr  	get_labelr   	enumerateset_position)r@   rA   r  redrawr|  r   rN   ax_colorbarspositionspecsr  bboxr"  r#  wr  ra  paddingr%  offsetscaled_wr  r   ro   i_artist_spec_labels                               rG   r  zColorbarPlot._draw_colorbarP  sR   ?inG!!(D11l5!|F#!-!8!<!<RXXDz!R!Rh<<|<<<}W%%6 "
!!!$$&&D$'4:t{BJAq!QQ!JAq!Q i%% 	,!+I)))44	;"KEE 	*EE] 	M!$1EEE#85  &&FwH,,!GXg-=af-Df,L L !8Q 0 1 1C3< ?CD'? ?+/+=? ?D$$TW]ItOOOdE9555"%DL#'DL Y((**FL-...3-?...dE :;;;09,0G0G 	/ 	/,A,eVwHac'k8G+;AdF+BA*EE1. / / / / .:Aq!Q<,H4)))rM   r=  c                     t          |          }|t          |t                    r|                    |d          }nt          |t                    o?|j        j        o3t          |dd          dup |j                            ||j	        d           }t          j        |                    ||                    }|dz    j        vr| j        |dz   <   |                    |dz   d          }	|	, j        %t!          d  j        D                       r j        }	|	at#          |          sd	}	d
}
nZ|j        j        dv r||v r1 j        rd||         v r||         d         }	n1||         d         }	n!t          |t                    r|j        j        dk    r)|                                |                                f}	nt#          |          dk    rt          j        t          j        f}	n	 t1          j                    5  t1          j        dd           t          j        |          t          j        |          f}	ddd           n# 1 swxY w Y   n=# t:          $ r t          j        t          j        f}	Y nw xY w|                    |          }	 j        r2|	d         dk    r&||dk                                             |	d         f}	 j         rMt          j!        |	                                           t          j!        |	                                          f}	d
}
net          |          }||v rd||         v r||         d         }ntE          j#        |          }dt#          |          dz
  f}	d}
n|j        j        dv}
 j$        dk    r)tK          |	d         |	d          j&                  ||dz   <    j$        dk    s j        rh j         r7tO          j(        |	d         |	d         |	d         t          j)        z            }n"tO          j*        |	d         |	d                   }|||dz   <   |	d         ||dz   <   |	d         ||dz   <   |+                    |dz   |+                    dd                    |j        j        dvrd}t           j,        tZ                    r j,        }nzt           j,        t\                    r`t#           j,                  dz
  }t          t\                    r4t#                    |k    r!t_          d|t#                    fz            	 t          j        |          t          j        |          }}nM# t^          $ r t          j0         t          j0        }}Y n(w xY w|	d          dz   }t          j0         t          j0        }}||dz            t          j0         n
||dz            }||dz            t          j0        n
||dz            } j1        7||k     r||k    rd! _1        n#||k     rd" _1        n||k    rd# _1        nd$ _1        i  j2        3                                D ]\  }}|d%k    r	d&dd'|<   t          |th                    r,|dd(         t#          |          d(k    r|d(         ndd'|<   Ut          |tj                    rY|}d}|6                    d)          r8t#          |          d*k    r%t[          |d+d         d,          d-z  }|dd+         }||d'|<   t          tN          j7                  st          tp                    rQt          |          }||v rd||         v r||         d         }ntE          j#        |          } fd.|D             }nKts          ||
/          }t           j,        t\                    rtu          | j,        ||f0          \  }\  }}tO          j;        |          ty          j<                  d#v r j=        d2i d#          d"v r j>        d2i d"          d1v r j?        d2i d1          ||dz   <   dS )3zl
        Returns valid color normalization kwargs
        to be passed to matplotlib plot function.
        NT)r  level)expandedr  climsc              3   >   K   | ]}t          j        |          V  d S rJ   )r   isfinite)rR   cls     rG   rT   z,ColorbarPlot._norm_kwargs.<locals>.<genexpr>  s-      9`9`PR$-:K:K9`9`9`9`9`9`rM   )r   r   FuifrobustcombinedMr   r  z All-NaN (slice|axis) encounteredr   r~  r  )r  r  rescale_discrete_levelsr  rW   )r  r  	linthresh)r  r  r  r  r0   viridisr  zwThe number of colors in the colormap must match the intervals defined in the color_levels, expected %d colors found %d.r  r  rj  r   r  transparentr8  )r  r/   r   #	      g     o@c           
      ~    g | ]9}                     |                     d dj        i          d                   :S )NaNr  )rp  _default_nan)rR   r  r0   colorsr@   s     rG   r   z-ColorbarPlot._norm_kwargs.<locals>.<listcomp>  sS     - - -   88Avzz%'4CT9U'V'VW^'_`` - - -rM   )categorical)cliprT  rK   )@r   r9   r   r  r
   	interfacemultir   isuniquer  r   asarraydimension_valuesr_   r  climrk   r   r  r  clim_percentilerj  r   r  r  r  r  nanminnanmaxr=   rW  r   	symmetricr   r   r  cnormr   rK  
mpl_colors
SymLogNormrE   LogNormrp  color_levelsr   r`   r  infr-  clipping_colorsr   rO  r~   r   Colormapro  r   r   ListedColormapcopyset_over	set_underset_bad)r@   rA   r   optsvdimr:   r  dim_namerB  r^  rW  r  r~  r  ncolorsel_minel_maxr  r  r  r   r  r/   paletter0   rV  s   `                       @@rG   r  zColorbarPlot._norm_kwargs  sR	   
 !&&>$$$ 	WG$77 w00 J%+JWgt44D@ I%..w	4HH	 G$<$<TH$<$U$UVV +T\11/3DL+,xxw-- <DI1c9`9`VZV_9`9`9`6`6`19D<v;; '##"e++v%%+ <F8<L0L0L%h/9%h/
;c** /|(C//%zz||VZZ\\9V))!vrv~2!)!8!:!: N N ( 7Be f f f(*	&(9(929V;L;L'MN N N N N N N N N N N N N N N  ) 2 2 2#%626>DDD2 #==..D9 B Aw!|| &vqy 1 5 5 7 7aA> CF4LL,,...t0@0@0B0BBD#)$//	&&9y8I+I+I$Y/	:GG"/77G3w<<>*" ,+58K:"""1!W47(,(D# # #D :$)~ F!,$q'Q7;Awrt|E E E ")tAwT!WEEE"&D"1gVF]"1gVF]xxvtxx	'B'BCC<F**G$+S11 =+D-t44 =d/0014dD)) =c$ii7.B.B$ &R )0T';&< = = =1!#6!2!2BIf4E4E 1 1 1"$&"&1 2hqjG fWbfFFvf}-5ww4v;NfVm,4rvv$vf}:M#}}$#)  $#(  $#(  #,  *0022 	= 	=FAsm##&)A66q		C'' 	=&)"1"g03C1c!ff!E Eq		C%% =##C(( 'SZZ1__bcc
B//4E!#2#JE&+e<<q	$
 344 	6$%% k *$//	&&9y8I+I+I$Y/	:GG"/77G- - - - - -$+- - - 'tW+NNNd/66 k,;GTEV^bdh]i,j,j,j)G\dD,W55DyF??MDM::F5M:::F??NDN;;VE];;;F??LDL996%=999"VF]sH   8I! >I	I! II! II! !"JJ7(U   #VV)NNT)Nr=  )-r   r  r  r>   r  r  Tupler   r  r^  r  r   r   boolr_  r~   r   r  r   r/  r  r   Dictr.  r`   rg  ObjectSelectorrc  ri  r  r*  r  r  r+  r-  rK  rb  r  rU  r6   r  r   r  r  r  r  s   @rG   r  r    s       U\$ -0 1 1 1F 5;/ @! " " "D
 *e)%eT@R Y' ( ( (O
 %$c6#3\B I89 9 9J u}U 1' ( ( (H EJr 0E F F FM '5&tS$K NH I I IL !E ;W;W;W ^B C C CE !ej 20 1 1 1O  5< 35 6 6 6L ! 4   J d 1@ A A AJ '%&1114 FK  K
 ,emD ?J K K K e 2? @ @ @I JL* * * * *  D0 0 05I 5I 5I 5Ip[# [# [# [# [# [# [# [#rM   r  c                      e Zd Z ej        dd          Z ej        dd          Z ej        i d          Z	 ej
        g ddd	
          Z ej        i d          Zi i  edd           edd           eddddd           eddddd           ed           ed           ed           ed          d
Zed             ZdS )
LegendPlotTz-
        Whether to show legend for the plot.r%   Nz/
       Number of legend columns in the legend.z8
        A mapping that allows overriding legend labels.)
innerr  r  r  r  best	top_righttop_leftbottom_leftbottom_rightr}  aG  
        Allows selecting between a number of predefined legend position
        options. The predefined options may be customized in the
        legend_specs class attribute. By default, 'inner', 'right',
        'bottom', 'top', 'left', 'best', 'top_right', 'top_left',
        'bottom_right' and 'bottom_left' are supported.r  r  )g333333ÿr   r   )bbox_to_anchorloc)g?r   r   )        gRQ?r   &1?r   expandr  )r  ncolr  modeborderaxespad)r  g      пr   r  g?)r  r  r  r  r  )r     )
r}  r~  r  r  r  r  r  r  r  r  c                     | j         | j                 }| j        r
| j        |d<   | j                                        } |j        di t          |fi |                     d           |S )Nr  r   rK   )legend_specslegend_positionlegend_colslegend_optsrl  re  ro  rg   )r@   leg_specr  s      rG   r  zLegendPlot._legend_optsP  sv    $T%9:@0@Xf-&++--HHT(GGdnnX.F.FGGHHHrM   )r   r  r  r>   r  ru   r  r  ry  r`  rz  r  r  ro  r  propertyr  rK   rM   rG   r|  r|  &  s       %- 30 1 1 1K  %- 32 3 3 3K EJr 0; < < <M +e* 4D 4D 4D 4; A;< < <O %*R .E F F FK  "d)CCC"d)CCC"d2F()qxrS S S"da2G146 6 6 "&! $#'4A;;;$(DQKKK1 1L   X  rM   r|  c                   p     e Zd ZdZddgZg dZd fd	Zd Zd Ze	dd	            Z
e	dd
            Z xZS )OverlayPlotzN
    OverlayPlot supports compositors processing of Overlays across maps.
    r   rN   )%r   fig_sizerv   ry   r   r   rb   r   r   rE  rx   rz   r|   r   r   r   r   r   r   r   r  r  r
  rO   title_formatr9  rm   ro   rq   r*  r,  zlimr   r   r   	fontscaler  Nc                 x    d|vr|                      |          |d<    t                      j        |fd|i| d S )Nr;   r   )_get_projectionr5   r6   )r@   overlayr   rB   rF   s       rG   r6   zOverlayPlot.__init__j  sP    v%%#'#7#7#@#@F< :::6:::::rM   c                 h    | j                                         D ]}|                    |           d S rJ   )r[   r:   r   )r@   rA   subplots      rG   r   zOverlayPlot._finalize_artisto  s@    }++-- 	. 	.G$$W----	. 	.rM   c                 *   g }d}|j         }d                    d |D                       }| j        }| j                                        D ]X\  }}	|j                            |d          }
|	j        r|
s+d                    d |D                       }|	                    d d g          }t          |	dd	          d}wt          |t                    rGd
                    d t          ||          D                       }|r|                    ||f           t          |	t                    r2||	j                            di                                           z  }|
j        r7|r5|                    ||                    |
j        |
j                  f           Z|rt#          t          |           ng g f\  }}i }g }t          ||          D ]k\  }}t          |t"                    rt%          |          }t%          d |D                       }|sE|r$||vr |r||vr|||<   |                    |           lt'          t)          |                                                    dk    r| j        s5|                                }|r|s| j        s|                    d           n |j        t#          |                                          t#          |                                          fd|i| j        }|                     d          }|r-|                                                    |d                    |                    d           || j        d<   | j        d                             |           || j        d<   d	S )zi
        Accumulate the legend handles and labels for all subplots
        and set up the legend
        Tz, c                     g | ]	}|j         
S rK   )ra  r  s     rG   r   z.OverlayPlot._adjust_legend.<locals>.<listcomp>{  s    777q17777rM   Fc                     g | ]	}|j         
S rK   r  r  s     rG   r   z.OverlayPlot._adjust_legend.<locals>.<listcomp>  s    :::!qv:::rM   c                     | j         d         S Nr|  r_   r  s    rG   rL   z,OverlayPlot._adjust_legend.<locals>.<lambda>  s    	(0C rM   c                     d| j         v S r  r  r  s    rG   rL   z,OverlayPlot._adjust_legend.<locals>.<lambda>  s    QY1F rM   _legend_plotN,c                 8    g | ]\  }} |j         |d           S )T)
print_unitr  )rR   r  r   s      rG   r   z.OverlayPlot._adjust_legend.<locals>.<listcomp>  sD     "F "F "F&,a #3#"21"F"F"F "F "F "FrM   legend_datac              3   R   K   | ]"}t          |t          t          f          |V  #d S rJ   )r9   r   r`   )rR   r  s     rG   rT   z-OverlayPlot._adjust_legend.<locals>.<genexpr>  s6      UUJq9dBS4T4TU1UUUUUUrM   r   rO   legend_titler   g    cAr   rV   )r  joinr`  r[   r   r  rp  ru   r\   r   r9   r   r   r   r  r_   ra  r`   rO  r   setr:   rs   rt   r   r  r  rg   	get_titleset_fontsize
set_zorder)r@   r  rN   r  legend_plotr^   rO   r\  r   r  rA   rv  ra  all_handles
all_labelsr  used_labelsr   r  title_fontsizes                       rG   _adjust_legendzOverlayPlot._adjust_legends  s   
 ]
		77J77788# M//11 	W 	WLCl&&sE22G&?g?xII::z:::;;E%%&C&C'F'F&GI IFw55A"GY// W "F "F03C0D0D"F "F "F G G 8&&777G[11 Ww22="EEKKMMM W6 W""FFJJw}gm,T,T#UVVV=H"V$sK'8"9"9"9rSUhZ j99 	* 	*MFE&$''?%--UUfUUUUUF  *6--5-U+=U=U$V""5)))C&&''!++D4D+__&&F *{ *d.> *""5)))$+d499;;//dkkmm1D1D @ @$)@-1->@ @C!^^N;;N I,,^J-GHHHNN4   %(DL"L-.55c:::&*]###rM   c                    | j         d         }| j        d         }|                     |          }|                     | j        ||          }| j                                        D ]M\  }}|                    |           t          |t                    r|
                    |d           }||_        N| j        r||                     ||           |                     ||||                     |                    S )NrN   r  )r   )rA   r   rO   )r_   r  rY   rk  r7   r[   r   r  r9   r	   rp  rZ   ru   r  r   re   )r@   r   rN   r   rA   r  r  frames           rG   r  zOverlayPlot.initialize_plot  s   |F#im//#&&$$TYV<<---// 	. 	.JAw##6#222'#344 .At,,(-% 	/ 3...""3)-););C)@)@ # B B 	BrM   c                    | j         d         }t          | j        t                    o| j        }| j        | _        ||s|                     |          }n||| _        || _        |d u }t          | j        t                    r|}n| j        }|g n%t          |j
                                                  }|s|                     |||          }| j                                        D ]\  }	}
|rd n|                    |	d           }t          | j        t                    rP|sN|                     |	|
||          \  }}}|0|                    |          \  }}|s|                     |
|           |
                    |||           t          | j        t                    r|r|                     |||           |                     |d          j        |                     |d| j        d          } j        di fd|                                D               | j        j        di  | j        r|s|                     ||           |                     |||           d S )NrN   r   F)defaultsc                 0    i | ]\  }}|v	||d          S )r   rK   )rR   r  r  	plot_optss      rG   r  z,OverlayPlot.update_frame.<locals>.<dictcomp>  s7     3 3 31 	11 qt111rM   rb  rK   )r_   r9   r7   r   r  rZ   rc  rY   rd  r`   r  r   rk  r[   rp  _match_subplotr  _update_subplotry  _create_dynamic_subplotsrf  rg  _traverse_options_propagate_optionsre  r>   ru   r  r   )r@   r   r   rA   rN   rs  empty	range_objr   r  r  r   idxr  exactr(  	inheritedr  s                    @rG   ry  zOverlayPlot.update_frame  s   |F#DIz22Dt}-?6?ooc**GG !(D"D4di,, 	"II	Io40B0B0D0D+E+E 	A((C@@F---// 	2 	2JAw8GKK4$8$8B$)Z00 < <#'#6#6q'5'#R#R T5?!IIcNNEAr  <,,Wd;;;  fb1111di,, 	> 	>))#uf=== ''88@	**7F+/+B49 + ; ;	 		 	4 	4 3 3 3 3	0A0A 3 3 3 	4 	4 	4
&&I&&& 	/E 	/...C@@@@@rM   rJ   r  )r   r  r  __doc___passed_handlesr  r6   r   r  r   r  ry  r  r  s   @rG   r  r  Y  s          foO) ) ); ; ; ; ; ;
. . .4+ 4+ 4+l B B B ^B$ ,A ,A ,A ^,A ,A ,A ,A ,ArM   r  )5rl  r  r  typesr   matplotlib.colorsrV  rd  numpyr   r>   
matplotlibr   matplotlib.datesr   matplotlib.imager   packaging.versionr   corer	   r
   r   r   r   r   r   core.optionsr   r   rA   r   r   streamsr   util.transformr   r   r   r   r   r   r   r   r   r   r    r!   r"   r$   r  r|  r  rK   rM   rG   <module>r     s            & & & & & &            % % % % % % & & & & & & % % % % % %                  < ; ; ; ; ; ; ; " " " " " " " "       ! ! ! ! ! ! 9 9 9 9 9 9 9 9 ? ? ? ? ? ? ? ? ? ? ) ) ) ) ) ) ) ) H H H H H H H H H H H Hs
, s
, s
, s
, s
,$g s
, s
, s
,pJ# J# J# J# J#; J# J# J#Z
0 0 0 0 0 0 0 0fPA PA PA PA PA*0 PA PA PA PA PArM   