
    LeF                        d dl mZ d dlmZ d dlZd dlZd dlZd dlm	Z	m
Z
mZmZ d dlmZ d dlmZ ddlmZmZmZmZmZmZmZmZmZmZ dd	lmZmZ dd
l m!Z!m"Z"m#Z# ddl$m%Z%m&Z&m'Z'm(Z(m)Z) ddl*m+Z+m,Z,m-Z- ddl*m.Z.m/Z/m0Z0 ed             Z1d Z2 G d de%          Z3 G d de'e3          Z4 G d de4          Z5 G d de3e&          Z6 G d de)e4          Z7 G d de%          Z8dS )    )contextmanager)chainN)	animationgridspecpyplotrcParams)font_scalings)Axes3D   )
AdjointLayoutCollatorCompositeOverlayElementEmpty
GridMatrix	GridSpaceHoloMapLayoutNdLayout)SkipRenderingStore)int_to_alphaint_to_romanwrap_tuple_streams   )DimensionedPlotGenericAdjointLayoutPlotGenericCompositePlotGenericElementPlotGenericLayoutPlot)attach_streamscollatedisplayable   )compute_ratios
fix_aspectget_old_rcparamsc              #     K   t                      }t          j                                         t          j                            t          |fi |            	 dV  t          j                                         t          j                            |           dS # t          j                                         t          j                            |           w xY w)zI
    Context manager that temporarily overrides the pyplot rcParams.
    N)r'   mplr   clearupdatedict)rcparamsold_rcparamss     ;lib/python3.11/site-packages/holoviews/plotting/mpl/plot.py_rc_contextr0   )   s      
 $%%LLL\66X66777*L))))) 	L))))s   B ?Cc                       fd}|S )z
    Decorator for MPLPlot methods applying the matplotlib rc params
    in the plots fig_rcparams while when method is called.
    c                 x    t          | j                  5   | g|R i |cd d d            S # 1 swxY w Y   d S N)r0   fig_rcparams)selfargskwargsfs      r/   wrapperzmpl_rc_context.<locals>.wrapper<   s    *++ 	, 	,1T+D+++F++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,s   /33 )r8   r9   s   ` r/   mpl_rc_contextr;   7   s#    
, , , , , N    c                   V    e Zd ZdZdZi Z ej        i d          Z ej	        ddd          Z
 ej        d	d
          Z ej        dd          Z ej        dd          Z ej        i d          Z ej	        ddd          Z ej        g d          Z ej        ddd          Z ej        dd          Z ej	        dd          Z ej        dd          Z ej        dd          ZdZd( fd	Zed             Zd  Zd! Z d" Z!e"d#             Z#d)d&Z$d' Z% xZ&S )*MPLPlota|  
    An MPLPlot object draws a matplotlib figure object when called or
    indexed but can also return a matplotlib animation object as
    appropriate. MPLPlots take element objects such as Image, Contours
    or Points as inputs and plots them in the appropriate format using
    matplotlib. As HoloMaps are supported, all plots support animation
    via the anim() method.
    
matplotlibaL  
        A dictionary of custom options to apply to the plot or
        subcomponents of the plot. The keys in the dictionary mirror
        attribute access on the underlying models stored in the plot's
        handles, e.g. {'colorbar.margin': 10} will index the colorbar
        in the Plot.handles and then set the margin to 10.defaultdoc      ?)r   r$   z0
        Alpha of the overall figure background.rA   boundsrB   )333333?rF   333333?rG   z
        The bounds of the overall figure as a 4-tuple of the form
        (left, bottom, right, top), defining the size of the border
        around the subplots.   a  
        The overall matplotlib figure size in inches.  May be set as
        an integer in which case it will be used to autocompute a
        size. Alternatively may be set with an explicit tuple or list,
        in which case it will be applied directly after being scaled
        by fig_size. If either the width or height is set to None,
        it will be computed automatically.Fz9
        Whether to use LaTeX text in the overall figure.zA
        matplotlib rc parameters to apply to the overall figure.      Y@)r$   NzE
        Size relative to the supplied overall fig_inches in percent.z
        Optional list of hooks called before plotting the data onto
        the axis (now marked for deprecation). The hook is passed the
        plot object and the displayed object; other plotting handles
        can be accessed via plot.handles.NTz
        Allows labeling the subaxes in each plot with various formatters
        including {Alpha}, {alpha}, {numeric} and {roman}.)rA   
allow_NonerB   )gffffffֿrG   zQ
         Position relative to the plot for placing the optional subfigure label.   z+
         Size of optional subfigure label.a"  
        The projection of the plot axis, default of None is equivalent to
        2D plot, '3d' and 'polar' are also supported by matplotlib by default.
        May also supply a custom projection that is either a matplotlib
        projection type or implements the `_as_mpl_axes` method.zA
        Whether or not to show a complete frame around the plot.c                 "    d _          t                      j        d	i |  j        dz   _        t           j        t          t          f          r fd j        D              _        n xj         j        z  c_         j	        r
d j
        d<    j        j        rt          j                     d _        n j        j        st          j                                          ||          \  }}| j        d<   | j        d<   g  j        d<   d S )
NTrI   c                 ,    g | ]}|d n	|j         z  S r3   )	fig_scale).0ir5   s     r/   
<listcomp>z$MPLPlot.__init__.<locals>.<listcomp>   s8     9 9 9#$ ()ytta6F 9 9 9r<   ztext.usetexFfigaxisbbox_extra_artistsr:   )_create_figsuper__init__fig_sizerN   
isinstance
fig_inchestuplelist	fig_latexr4   rendererinteractivepltion_close_figuresnotebook_contextioff
_init_axishandles)r5   rR   rS   params	__class__s   `   r/   rW   zMPLPlot.__init__   s%   ""6"""t+dot}55 	.9 9 9 9(,9 9 9DOO OOt~-OO> 	4/3Dm,=$ 	GIII"'D/ 	HJJJOOC..	T!U#V-/)***r<   c                 V   |s#| j         rt          j                    }| j        \  }}}}| j        }|                    ||||           |j                            | j                   t          |t          t          f          rYt          |          }|d         |d         |d<   n|d         |d         |d<   |                    t          |                     n|                    ||g           |                    d| j                  }|                    d           ||fS )z\
        Return an axis which may need to be initialized from
        a new figure.
        )leftbottomrighttopr   Nr$   o   
projectionauto)rU   r`   figure
fig_boundsrZ   subplots_adjustpatch	set_alpha	fig_alpharY   r[   r\   set_size_inchesadd_subplotrp   
set_aspect)r5   rR   rS   lbrtinchess           r/   re   zMPLPlot._init_axis   s&     	$t' 	$*,,CJAq!Q_FQqqAAAI///&5$-00 6f!9$ &q	F1IIAY& &q	F1I##DLL1111##VV$4555??34??CCDOOF###Dyr<   c                 V   t           d         }t           d         t           d         t           d         t           d         t           d         d}t          |          }|                                D ]-\  }}t          |t                    r|t
          |         z  ||<   .|d         |d	<   |S )
Nz	font.sizezaxes.labelsizezaxes.titlesizezxtick.labelsizezytick.labelsizezlegend.fontsize)labeltitlexticksytickslegendr   ticks)r   r,   itemsrY   strr	   )r5   basesizesscaledkvs         r/   _get_fontsize_defaultszMPLPlot._get_fontsize_defaults   s    $././010101
 
 eKKMM 	4 	4DAq!S!! 4 =#33q	 *wr<   c           
         | j         r| j        nd}| j        rc| j        s]|dk    rXddlm} i }d| j        v rt          |dz
            |d<   n~d| j        v rt          |dz
  d          |d	<   n]d
| j        v r| j        |d<   nId| j        v rt          |          |d<   n-d| j        v r$t          |                                          |d<    | | j        j	        di |d| j
        dt          | j        d          |j                  }|j                            d           |                    |           |j                                        d         }|| j        d<   | j        dxx         |gz  cc<   d S d S d S d S )Nr$   r   )AnchoredTextz{Alpha}Alphaz{alpha}F)upperalphaz	{numeric}numericz{Roman}Romanz{roman}romanr   bold)sizeweight)locbbox_to_anchorframeonpropbbox_transformsublabelrT   r:   )subplot
layout_numsublabel_formatadjoinedmatplotlib.offsetboxr   r   r   lowerformatsublabel_positionr,   sublabel_size	transAxesru   set_visible
add_artisttxtget_childrenrf   )r5   rS   r   r   labelsatr   s          r/   _subplot_labelzMPLPlot._subplot_label   s   (,;T__!
 	= 	=*q..999999FD000".z!|"<"<wd222".z!|5"I"I"Iw 444$(Oy!!d222".z":":wd222".z":":"@"@"B"Bw9d29CCFCC-1-CU#'T-?#O#O#O-1^= = =B H  '''OOBv**,,Q/H'/DL$L-...8*<.....+	= 	= 	= 	=..r<   c                 
   d| j         v r%| j         d                             | j                   d| _        | j        r| j         d         S | j         d         }t          | dd          s| j        rt          j        |           |S )z?
        General method to finalize the axis and plot.
        r   TrS   rR   overlaidF)	rf   r   
show_titledrawnr   getattrrb   r`   close)r5   keyrR   s      r/   _finalize_axiszMPLPlot._finalize_axis   s     dl""L!--do>>>
< 	<'',u%C4U33 8K 	#Jr<   c                     | j         d         S )NrR   )rf   r5   s    r/   statezMPLPlot.state   s    |E""r<   r      c                     | j         p|                                 }t          j        || j        | j        d|z            }| j        rt          j        |           |S )z
        Method to return a matplotlib animation. The start and stop
        frames may be specified as well as the fps.
        g     @@)framesinterval)	r   initialize_plotr   FuncAnimationupdate_framekeysrb   r`   r   )r5   startstopfpsrr   anims         r/   r   zMPLPlot.anim  se    
 5t3355&vt/@.2i28*> > > 1	& 1 1 1r<   c                     t          |           dk    r,|d| j        d         fv r| j        s|                                 S |                     |          S )Nr$   r   )lenr   r   r   __getitem__)r5   r   s     r/   r+   zMPLPlot.update  sS    t99>>ca1%666tz6'')))$$$r<   NN)r   Nr   )'__name__
__module____qualname____doc__backend	sideplotsparamDictbackend_optsNumberrw   NumericTuplers   	ParameterrZ   Booleanr]   r4   rX   HookListinitial_hooksStringr   r   r   rp   
show_framerb   rW   r;   re   r   r   r   propertyr   r   r+   __classcell__rh   s   @r/   r>   r>   B   s         GI5:b /> ? ? ?L S >3 4 4 4I $#,D, ! ! !J ! 1. / / /J e 2< = = =I 5:b /D E E EL u|D AH I I IH #EN2 4- . . .M #el4D G> ? ? ?O +*= GT U U U !EL 2. / / /M ! 4D E E EJ u 3D E E EJ N0 0 0 0 0 04   ^2  "= = =6  " # # X#   % % % % % % %r<   r>   c                   `    e Zd ZdZ ej        dd          Zd Zd Zd Z	e
d
d	            ZdS )CompositePlotzi
    CompositePlot provides a baseclass for plots coordinate multiple
    subplots to form a Layout.
    Tz
        Whether axes ranges should be shared across the layout, if
        disabled switches axiswise normalization option on globally.r@   c                 n      fd j         D             }|D ]}|                     j        d           dS )zo
        Should perform any linking required to update titles when dimensioned
        streams change.
        c                 T    g | ]$}t          fd |j        D                       "|%S )c              3   *   K   | ]}|j         v V  d S r3   )
dimensions)rO   r   r5   s     r/   	<genexpr>zECompositePlot._link_dimensioned_streams.<locals>.<listcomp>.<genexpr>%  s*      1[1[1!t2F1[1[1[1[1[1[r<   )anycontents)rO   sr5   s     r/   rQ   z;CompositePlot._link_dimensioned_streams.<locals>.<listcomp>%  s?    \\\c1[1[1[1[PQPZ1[1[1[.[.[\1\\\r<   r$   N)streamsadd_subscriber_stream_update)r5   r   r   s   `  r/   _link_dimensioned_streamsz'CompositePlot._link_dimensioned_streams   sV    
 ]\\\dl\\\ 	5 	5AT0!4444	5 	5r<   c                     d | j         D             t          fdt          | j        | j                  D                       }t          || j        | j                   }|                     |           d S )Nc                 &    g | ]}|j         D ]}|S r:   )r   )rO   r   r   s      r/   rQ   z0CompositePlot._stream_update.<locals>.<listcomp>*  s'    @@@!QZ@@A@@@@r<   c              3   .   K   | ]\  }}|v rd n|V  d S r3   r:   )rO   dr   r   s      r/   r   z/CompositePlot._stream_update.<locals>.<genexpr>+  s3      ddTQAMMDDqddddddr<   )r   r[   zipr   current_keyr   _update_title)r5   r7   r   r   s      @r/   r   zCompositePlot._stream_update)  sy    @@t|@@@ddddSRVRb=c=cddddd dot|DD3r<   c                 B   | j         r|                     |          nd}d| j        v r"| j        d                             |           d S d| j        v rJ| j        d         j        : | j        d         j        |fi |                     d          }|| j        d<   d S d S d S )N r   rS   )r   _format_titlerf   set_textrr   	set_title	_fontsize)r5   r   r   s      r/   r   zCompositePlot._update_title/  s    +/?B""3'''dl""L!**511111t|##V(<(C(O2DL(25TTDNN7<S<STTE$)DL!!! $#(O(Or<   Nc                     |                      | j        ||          }| j                                        D ]}|                    ||           |                     |           d S )Nranges)compute_rangeslayoutsubplotsvaluesr   r   )r5   r   r   r   s       r/   r   zCompositePlot.update_frame7  sn    $$T[#v>>}++-- 	5 	5G  V 44443r<   r3   )r   r   r   r   r   r   shared_axesr   r   r   r;   r   r:   r<   r/   r   r     s         
  %- 3H I I IK5 5 5     * * *       ^     r<   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 ej	        dd	          Z ej        d
g dd          Z ej        dg dd          Z ej        ddd          Z ej        ddd          Z	 	 d  fd	Zd Zd Zed!d            Zd Zd Zd Z xZS )"GridPlotz\
    Plot a group of elements in a grid layout based on a GridSpace element
    object.
    equalzF
        Aspect ratios on GridPlot should be automatically determined.r@   皙?zC
        The amount of padding as a fraction of the total Grid sizeFz
        If enabled the x-axes of the GridSpace will be drawn from the
        objects inside the Grid rather than the GridSpace dimensions.zK
        Legends add to much clutter in a grid and are disabled by default.rk   )rk   rm   Nzh
        Whether and where to display the xaxis, supported options are
        'bottom', 'top' and None.)rA   objectsrB   rj   )rj   rl   Nzh
        Whether and where to display the yaxis, supported options are
        'left', 'right' and None.r   )r   ih  z&
        Rotation angle of the xticks.rD   z&
        Rotation angle of the yticks.NTr$   c                     t          |t                    st          d           t                      j        |f|||d| i }|K|                                }	|	j        |	j        |	j        |	j	        f\  }
}}}|
|
|z   |||z   d}|
|||f _
        |j        \   _         _                                          _        t!          j         j         j        fi | _        t'          j         j                  5                       ||||          \   _         _         _        d d d            n# 1 swxY w Y    j        r!                      fdt8          g           d S d S )Nz GridPlot only accepts GridSpace.)r   r   r   )rj   rl   rk   rm   rcc                 0    t          | j        d          S Nr   r!   hmapxr5   s    r/   <lambda>z#GridPlot.__init__.<locals>.<lambda>}      N4$C$C r<   )rY   r   	ExceptionrV   rW   get_positionx0y0widthheightpositionshapecolsrows	_get_sizerZ   r   GridSpec_layoutspecr)   
rc_contextr4   _create_subplotsr   subaxesr   	top_leveltraverser   )r5   r   rS   create_axesr   r   r   rg   grid_kwargsbboxr{   r|   whrh   s   `             r/   rW   zGridPlot.__init__g  s   &),, 	@>??? 	=J &T	= 	=5;	= 	= 	= $$&&D$'4:t{BJAq!Q#$qsa!LLK1aLDM%|	49..**#,TY	QQ[QQ^t0111 	b 	b7;7L7LVUYMSU`8b 8b4DM4<	b 	b 	b 	b 	b 	b 	b 	b 	b 	b 	b 	b 	b 	b 	b > 	0MMCCCC-.0 0 0 0 0	0 	0s   =,D55D9<D9c                    t          | j        j                  }d|z  }d|dz
  dz  z   }||z  }| j        j        \  }}t          | j        t
          t          f          rHt          | j                  }|d         |d         ||z  z  |d<   |d         |d         ||z  z  |d<   |S | j        fdz  }||z  |d         z  ||z  |d         z  fS )NrC   r$   r  r   r   )maxr   r  rY   rZ   r[   r\   )r5   max_dimshape_factorexpand_factorscale_factorr  r  rZ   s           r/   r  zGridPlot._get_size  s    dk'((G|Wq[C//$|3[&
ddot}55 
	9do..J!}$ *1d ;
1!}$ *1d ;
1/+A-J 4'*Q-7 4'*Q-79 9r<   c                 	                          ddgt          g          }t          |                    dg                     }|s% j        d                              j                   i i }}                     d |           j        r j	        d d         n j	        }	t           fd|	D                                           dj                  }
d\  }}	                    d	
          D ]B}t          |t                    s|f}j                            |d           }t!          |          t"          t$          fv rt'          d          t)          |          st+          |          }|?t          |t,                    r|j        n|j        }                     |d          j        }nd }i }|r|r                     |          nd }t7          j         j        ||f         |          }|s j        r j        d _        |s j         r j!        d _!         j        s j         r|s|dk    r%|dk    r|j        "                    d           d|d<   |dk    r0|dk    r*j#        dk    s|j!        "                    d           d|d<   |dk    r|dk    r
d|d<   d|d<    j        sd|d<    j         sd|d<   n
d|d<   d|d<   ||||f<   nd }|r@tI          |tJ                    r+| j&        dz
  k    r| j'        dz  k    r j(        |d<   d|d<   t           j)        tT                    s-| j&        dz  k    r|dk    s|dk    r| j'        dz  k    sg |d<   |t           j        d         | j+        d|  j,         j	        d j-        
  
        }t\          j/        d         |         } ||fi t          |fi t          |fi |}t          |t`                    r|j)        n|j1        |
|<   ||||f<   n||2                    d           | j'        dz
  k    r|dz  };d}|dz  }D|r? 3                    |           j        d<    4                     j        d         |           |||
fS )NnormaxiswiserR   r$   c                 B    g | ]}|                     |          fS r:   r   rO   r   frame_rangesr   r5   s     r/   rQ   z-GridPlot._create_subplots.<locals>.<listcomp>  @     5 5 5(+ "4#6#6vsL#Q#QR 5 5 5r<   Fshared_dataidr   r   T)	full_gridzCannot plot nested Layouts.plotro   rm   rl   r   nonezbottom-barexaxisz	left-bareyaxisr   show_legendlegend_positionlabelled)
rR   rS   r   r   r   r   uniformr   rA  r^   r?   rS   )5_traverse_optionsr   allgetrf   rx   rZ   r   dynamicr   r,   cloner:  rY   r[   datatyper   r   r   r#   r"   r   rh   lookup_optionsoptions_get_projectionr`   r   r  shared_xaxisr?  shared_yaxisr@  set_ticks_positionndims
issubclassr   r  r  rA  r   r   r   rD  r^   r   registryr   r  r   _layout_axis_adjust_subplots)r5   r   rS   r   r%  	norm_optsr2  r   r"  r   collapsed_layoutr}   ccoordviewvtypeoptsr7   rp   subaxrg   plotting_classr   r6  s   ``                     @r/   r!  zGridPlot._create_subplots  sU   **66J<'SS	y}}Z4455 	AL//@@@'**64@@ $;ty!}}$) 5 5 5 5 5 5/35 5 5 6 6!<<Efi<HH1[[4[00 I	 I	EeU++=eXU;??5$//DDzzfh///#$ABBBt$$ %t}}%/g%>%>R		DN**488@ F ;@JT11$777d
D$4QT$:zRRR 'D$5 '$*:P!&DJ )D$5 )$*:P!(DJ % 2): 2H 2Avv!q&&66v>>>*7wAvv!q&&1B1B66v>>>*5wAvv!q&&*7w*5w, 8*7w, 6*5w&3F7O&1F7O"'A 4E+;<< 4!tyST}BTBTBCtyRS|BSBS(,(8}%,3()t{J77 (ty!|##QaAA--%'z" $,u"5E)-U*5ol&*l*/$-	I I I
 "'!=e!D(.WW$t2V2VtF?U?Uf?U?U2V2VWW<FwP]<^<^*p'..dkdp '#*!Q  "!!%(((DIaKQQ 	A#'#4#4VT#B#BDL !!$,v"6@@@"222r<   c                    | j         d         }| j        d         }i }|                     | j        ||          }| j                                        D ]} |j        dd|i| | j        r> |j        | 	                    |          fi | 
                    d          }|| j        d<   |                     |           d| _        | j        r| j        d         S | j        rt          j        | j        d                    | j        d         S )NrS   r   r   TrR   r:   )r   rf   r   r   r   r  r   r   r   r   r   _readjust_axesr   r   rb   r`   r   )r5   r   r   rS   subplot_kwargsr   r   s          r/   r   zGridPlot.initialize_plot  s&    im|F#$$T[#v>>}++-- 	E 	EG#G#DD6D^DDDD? 	*"DN4#5#5c#:#: > >%)^^G%<%<> >E$)DL!D!!!
<4V 44>	$,u*= > > >|E""r<   c                 T   | j         r|                    | j                   | j        dk    r/|                    t          | j                  | j        z             | j        d         j	        
                                 |                     | j        d         | j                   d S d S )Nr  rR   rS   )r   set_positionr  aspectrz   floatr  r  rf   canvasdrawrV  r"  )r5   rS   s     r/   rb  zGridPlot._readjust_axes  s    < 	Fdm,,,{g%%di 0 0 :;;;L&++---!!$,v"6EEEEE	F 	Fr<   c                 	   | j         d         }|rdt          | j                  ini } |j        di |}|r/|                    d           |                    | j                   |j                            d           t          ddg|j        |j	        g          D ]/\  }}| 
                    | ddd	          }|r |j        di | 0 |j        |j        d
         j        fi | 
                    d           |j        dk    r1 |j        |j        d         j        fi | 
                    d           |j        |                                }	|j        dk    r-|	}
d
g}|                                                    d           n[t          |	 \  }
}|                    d         j                   |                    t)          | j                  | j        z             d| j        z
  | j        z  | j        dk    r| j        | j        dz
  z  nd
fdt1          | j                  D             }d| j        z
  | j        z  |j        dk    r| j        | j        dz
  z  nd
fdt1          | j                  D             }|                    |           |                    fdt7          t9          |
                    D                        |                                D ]}|                    | j                   |j        dk    rd         nd |                     |           |!                    fdt7          t9          |                    D                        |"                                D ]}|                    | j#                   | j$        sZ|j%        | j	        dk    rdnd                             d           |j%        | j        dk    rdnd                             d           |}| j        ?|j        &                    | j                   |j        '                    | j                   n|j                            d           | j	        ?|j	        &                    | j	                   |j	        '                    | j	                   n|j	                            d           dD ]"}|j%        |                             d           #|S )NrR   gid)r$   r$   r$   Fr  yr   	labelsize)commonr   xlabelr   r$   ylabelrC   c                 ,    g | ]}d z  |z   z  z   S r   r:   )rO   r}   border_width
plot_widths     r/   rQ   z)GridPlot._layout_axis.<locals>.<listcomp>5  s,    YYY1:a<!Z%<"=>YYYr<   c                 ,    g | ]}d z  |z   z  z   S rr  r:   )rO   r}   border_heightplot_heights     r/   rQ   z)GridPlot._layout_axis.<locals>.<listcomp>8  s,    \\\a;q=1k-&?#@A\\\r<   c                 F    g | ]}d                               |          S r   pprint_value)rO   r{   dimss     r/   rQ   z)GridPlot._layout_axis.<locals>.<listcomp>;  sA     %F %F %F)* &*!W%9%9!%<%< %F %F %Fr<   c                 B    g | ]}r                     |          nd S )r   rz  )rO   r{   ydims     r/   rQ   z)GridPlot._layout_axis.<locals>.<listcomp>B  sH     %F %F %F)* >B%IT%6%6q%9%9%9r %F %F %Fr<   rj   rl   rm   rk   )rj   rl   rm   rk   r:   )(rf   r   r  ry   r   re  ru   r   r?  r@  r   set_tick_params
set_xlabelkdimspprint_labelrR  
set_ylabelr   	get_yaxisrz   rg  r  r  paddingrange
set_xticksset_xticklabelssortedsetget_xticklabelsset_rotation	xrotation
set_yticksset_yticklabelsget_yticklabels	yrotationr   spinesrQ  set_label_position)r5   r   rS   rR   axkwargslayout_axisaxax_objtick_fontsizer   	dim1_keys	dim2_keysr   r   tickposrv  rs  r|  rw  rt  r~  s                   @@@@@@r/   rU  zGridPlot._layout_axis  sp   l5!26>E3t}--..B%co88x88 	4U###$$T]333%%e,,,sCj;+<k>O*PQQ 	F 	FJB NNb<<<ENRRME4f4EE}EEE 	v|A; 	; 	;!%!9!9	; 	; 	;<1"K"6<?#? ; ;!%!9!9; ; ; |{{}}<1II!!##//6666#&: Iy""47#7888""5#3#3DI#=>>> DL(DI5
7;y1}}t|ty{33!YYYYYdiHXHXYYYT\)TY68>q8H8H	!44a\\\\\5QUQZK[K[\\\v&&&## %F %F %F %F.4S^^.D.D%F %F %F 	G 	G 	G//11 	. 	.Ddn---- ,**tAwwv&&&## %F %F %F %F.4S^^.D.D%F %F %F 	G 	G 	G//11 	. 	.Ddn---- 	^$**>*>wwFKWWX]^^^4:+>+>xxEJVVW\]]]:!J))$*555J))$*5555J""5))):!J))$*555J))$*5555J""5)))5 	0 	0CK((////r<   c                 j   |                                 }|j        |j        |j        |j        f\  }}}}| j        r|d| j        z  z  }|d| j        z  z  }	nd\  }}	| j        dk    rd}
n|| j        dz
  z  }
| j        dk    rd}n|	| j        dz
  z  }|| j        dk    r|ndz
  | j        z  }|| j        dk    r|	ndz
  | j        z  }d\  }}|                                D ]T}|||z  z   ||
z  z   }|||z  z   ||z  z   }|| j        dz
  k    r|dz  }nd}|dz  }||	                    ||||g           Ud S )NrC   r;  r$   r   )
r  r  r  r  r  r  r  r  r  re  )r5   rS   r"  r'  r{   r|   r(  r)  width_paddingheight_paddingb_wb_hax_wax_hr}   rY  r  xposyposs                      r/   rV  zGridPlot._adjust_subplots^  s     ""Wdgtz4;>
1a< 	1r$,/M4<0NN,0)M>9>>CC49q=1C9>>CC DIM2Cdi!mm]];tyHty1}}^^!<	I1.."" 		: 		:B$<1s7+D$<1s7+DDIaKQQ~tT4 8999		: 		:r<   )NTNr$   Nr3   )r   r   r   r   r   r   rf  r   r  r   rO  rP  rA  ObjectSelectorr?  r@  Integerr  r  rW   r  r!  r;   r   rb  rU  rV  r   r   s   @r/   r  r  @  s        
 U_W 3I J J JF el3 -F G G GG !5= 5I J J JL !5= 5I J J JL  %- 4N O O OK !E )@)@)@ G%& & &E
 !E )@)@)@ G%& & &E
 a ?) * * *I a ?) * * *I DH$(0 0 0 0 0 029 9 9*Z3 Z3 Z3z # # # ^#*F F FJ J JZ :  :  :  :  :  :  :r<   r  c                   |     e Zd ZdZdgddgg dddgdZ fdZedd            Zdd
Zedd            Z	d Z
 xZS )AdjointLayoutPlota  
    Initially, a AdjointLayoutPlot computes an appropriate layout based for
    the number of Views in the AdjointLayout object it has been given, but
    when embedded in a NdLayout, it can recompute the layout to
    match the number of rows and columns as part of a larger grid.
    mainrl   )rm   Nr  rl   N)SingleDualTripleEmbedded Dualc                     || _         || _        | j        | j                 | _        d t	          || j                  D             | _         t                      j        dd|i| d S )Nc                     i | ]\  }}||	S r:   r:   )rO   r  r  s      r/   
<dictcomp>z.AdjointLayoutPlot.__init__.<locals>.<dictcomp>  s    QQQGBRQQQr<   r   r:   )r   layout_typelayout_dictview_positionsr   r"  rV   rW   )r5   r   r  r"  r   rg   rh   s         r/   rW   zAdjointLayoutPlot.__init__  sr    &".t/?@ RQs7D<O/P/PQQQ55(5f55555r<   c                 V   | j         D ]}| j                            |d          }| j                            |d          }| j                            |d          }d|||fv r|                                 o|                    |           |                                  d| _        dS )<  
        Plot all the views contained in the AdjointLayout Object using axes
        appropriate to the layout configuration. All the axes are
        supplied by LayoutPlot - the purpose of the call is to
        invoke subplots with correct options and styles and hide any
        empty axes as necessary.
        Nr   T)	r  r   rG  r   r"  set_axis_offr   adjust_positionsr   )r5   r   r  r[  r   r  s         r/   r   z!AdjointLayoutPlot.initialize_plot  s     & 		3 		3C;??3--Dm''T22G!!#t,,Bc7+++!!!##6#2222


r<   Tc                     | j         | j        | j        g}t          d |D                       }t          d |D                       }d| j        vs|s|sdS |r$| j        d         j                                         | j        d         j        d         }|                                }|r| j        d         }| j        d         }t          |t                    r|j
        }	|j        }
nd}	d}
|                    |j        |j        |
z  z   |j        |j        |	z  |j        g           t          |t"                    r|                    d	           |r| j        d
         }| j        d
         }t          |t                    r|j
        }	|j        }
nd}	d}
|                    |j        |j        |j        |
z  z   |j        |j        |	z  g           t          |t"                    r|                    d	           dS dS dS )aP  
        Make adjustments to the positions of subplots (if available)
        relative to the main plot axes as required.

        This method is called by LayoutPlot after an initial pass
        used to position all the Layouts together. This method allows
        LayoutPlots to make final adjustments to the axis positions.
        c              3      K   | ]}d |v V  	dS )rl   Nr:   rO   checks     r/   r   z5AdjointLayoutPlot.adjust_positions.<locals>.<genexpr>  s'      99Gu$999999r<   c              3      K   | ]}d |v V  	dS )rm   Nr:   r  s     r/   r   z5AdjointLayoutPlot.adjust_positions.<locals>.<genexpr>  s&      55U%5.555555r<   r  NrR   rS   rl         ?r  rm   )r  r"  r   rF  rf   rh  ri  r  rY   AdjoinedPlotsubplot_sizeborder_sizere  x1r  r  r  r  rz   r  y1)r5   redrawchecksrl   rm   main_axr'  r  r   r  r  s              r/   r  z"AdjointLayoutPlot.adjust_positions  s:    %t|T]C99&9999955f55555&&s&e&F 	.L&++----'/7##%% 	'g&BmG,G'<00 #&3%1#"OOTWtzK'??!W!Z,6E F F F '8,, 'g&&& 	'e$BmE*G'<00 #&3%1#"OOTW!Wt{['@@!Z|)CE F F F '8,, 'g&&&&&	' 	'' 'r<   c                 ~    | j         D ]4}| j                            |          }||                    ||           5d S r3   )r  r   rG  r   )r5   r   r   r  r   s        r/   r   zAdjointLayoutPlot.update_frame  sP    & 	2 	2Cm'',,G"$$S&111	2 	2r<   c                 Z    t          | j        dnt          | j                  dg          S )Nr$   )r+  r   r   r   s    r/   __len__zAdjointLayoutPlot.__len__  s(    *AADIBCCCr<   r3   )T)r   r   r   r   r  rW   r;   r   r  r   r  r   r   s   @r/   r  r    s          %X"G,;;;%)6N4 4K
	6 	6 	6 	6 	6    ^,-' -' -' -'^ 2 2 2 ^2D D D D D D Dr<   r  c                   v    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 ej        d
d          Z ej        dd          Z ej        dd          Z ej        ddid          ZdZd fd	Zd Zd ZddZed             Z xZS )
LayoutPlotz
    A LayoutPlot accepts either a Layout or a NdLayout and
    displays the elements in a cartesian grid in scanline order.
    Fz
      If aspect_weight is enabled absolute_scaling determines whether
      axes are scaled relative to the widest plot or whether the
      aspect scales the axes in absolute terms.r@   r   zp
      Weighting of the individual aspects when computing the Layout
      grid aspects and overall figure size.)皙?r  ffffff?r  z
      The bounds of the figure as a 4-tuple of the form
      (left, bottom, right, top), defining the size of the border
      around the subplots.zX
      Tightly fit the axes in the layout within the fig_bounds
      and tight_padding.r   zK
      Integer or tuple specifying the padding in inches in a tight layout.g      ?z
      Specifies the space between horizontally adjacent elements in the grid.
      Default value is set conservatively to avoid overlap of subplots.g333333?z
      Specifies the space between vertically adjacent elements in the grid.
      Default value is set conservatively to avoid overlap of subplots.r      T)rA   rJ   Nc                 F     t                      j        d||d| t          j         j                  5                       |          \   _         _         _        d d d            n# 1 swxY w Y    j	        r! 
                     fdt          g           d S d S )N)r   r   r	  c                 0    t          | j        d          S r  r  r  s    r/   r  z%LayoutPlot.__init__.<locals>.<lambda>  r  r<   r:   )rV   rW   r)   r   r4   _compute_gridspecr   r"  r   r#  r$  r   )r5   r   r   rg   rh   s   `   r/   rW   zLayoutPlot.__init__  s
   <T<<V<<<^t0111 	V 	V7;7M7Mf7U7U4DM4<	V 	V 	V 	V 	V 	V 	V 	V 	V 	V 	V 	V 	V 	V 	V> 	0MMCCCC-.0 0 0 0 0	0 	0s   )A..A25A2c                    =>?                                  }t          t                    rj        nd}i }i i }} j        D ]\  }}|                     j        r||fn||fd          \  }	}
t          |
t                    rt          d          t          |
t                    r|
nt          |
g          }||||f<   dddd}|t          |                   }|j
        }t          |t                    r|j        n|}|r                     |d          j        ni }|rvt          |                    d	d
          t                    sMt          |t                     rt"          j        n|                    d	d
          ? j        ?z  d
z    j        z
  ?nt"          j        ?|dv rs|                    dd          }t)          |          }|rG|t*          j        v r9t*          j        t)          |                   }d|j        |j        z   z  }dd|z  g}ndd
g}ndg}?rd?z  nt"          j        >|dv rs|                    dd          }t)          |          }|rG|t*          j        v r9t*          j        t)          |                   }d|j        |j        z   z  }d|z  dg}nd
dg}ndg}t          ?t          t)          d          f          s?fd|D             }>fd|D             }t          |          t          |          f}|                    |dg f          }|d
         |d         k    r|d
         |d
         g||<   ||         d
                             |           |                    |dg f          }|d         |d         k    r|d         |d
         f||<   ||         d
                             |           d t5          |                                          D             }d t5          |                                          D             }t#          j        d |                                D                       dz  }t=          |d          }t=          |          }t=          |          }t          |          t          |          } }d |D             }d |D             }t?          d |D                       }!|!t?          d |D                       z  }" j         r|!t#          j!        |          z  }!d\  }#}$t           j"        tF          tH          f          s j"        |!z  }#|#|"z  }$nU j"        d          j"        d
         |"z  }# j"        d
         }$n* j"        d
          j"        d         }# j"        d         |"z  }$|#r$|$r" j%        d         &                    |#|$g           tO          j(        | ||| j)         j*                   _+         j%        d         ,                                 d}%d}& j-        }'.                    dj/                  }( 0                    dd          = j1        r j2        dd
         n j2        })tg          = fd |)D                       =i i }+}* j        D ]e\  }}||         },||         }-|,|-fd!k    rd}n |,|-fd"k    rd}n|,|-fd#k    rd$}n
|,|-fd%k    rd}|||f         }
th          j5        |         }. 6                    |||f         |.d=d&          \  }	}	}/ 7                    |%||          \  }%}0|                    ||fd          \  }1}	t          t                    r|1rtg          tq          ||1                    }|||f         }2t          |2j
        t                     }3|
j
        |3rt          g           }2n^|
9                    d' tt          g          s$ j;        <                    |2j
         d(           l j        r| j=        z  |d
z   z   }&n|&d
z  }& fd)tq          |0|/          D             }4 6                    |2|.|=tg          tq          |.|4                    |3rdn|&*          }5|5\  }6}7}	|4|+||f<                        |
d          j        }8ti          |7||4|6fd j%        d         i|8}9|9|*||f<   t}          d+ |9j?                                        D                        o|'}'|1r|7|(|1<   g|'r}t           j@        tF          tH          f          r j@        \  }:};tg          |:|;,          }<ntg           j@         j@        ,          }<  j+        jA         j%        d         fd- jB        i|< |*|+|(fS ).a  
        Computes the tallest and widest cell for each row and column
        by examining the Layouts in the GridSpace. The GridSpec is then
        instantiated and the LayoutPlots are configured with the
        appropriate embedded layout_types. The first element of the
        returned tuple is a dictionary of all the LayoutPlots indexed
        by row and column. The second dictionary in the tuple supplies
        the grid indices needed to instantiate the axes for each
        LayoutPlot.
        Nr   z-Cannot render NdLayout nested inside a Layoutr  r  r  )r$   r   r   r=  rf  r$   )r  r  rl   g333333?rH   rC   )r  r  rm   c                     g | ]}|z  S r:   r:   )rO   wratiomain_aspects     r/   rQ   z0LayoutPlot._compute_gridspec.<locals>.<listcomp>[  s    PPP 4PPPr<   c                     g | ]}|z  S r:   r:   )rO   hratio
inv_aspects     r/   rQ   z0LayoutPlot._compute_gridspec.<locals>.<listcomp>\  s     Q Q Q*!4 Q Q Qr<   r   c                 $    g | ]\  }}|d          S ry  r:   )rO   __r   s      r/   rQ   z0LayoutPlot._compute_gridspec.<locals>.<listcomp>m  s     HHHur1adHHHr<   c                 $    g | ]\  }}|d          S ry  r:   )rO   ___r   s      r/   rQ   z0LayoutPlot._compute_gridspec.<locals>.<listcomp>n  s     JJJvsAadJJJr<   c                 2    g | ]}|d          D ]	}|D ]}|
S r$   r:   )rO   colratiosr}   s       r/   rQ   z0LayoutPlot._compute_gridspec.<locals>.<listcomp>p  s`     A A A),QA A%A A45  A A A A Ar<   Fc                 >    g | ]}t          j        |          r|nd S r  npisfiniterO   r}   s     r/   rQ   z0LayoutPlot._compute_gridspec.<locals>.<listcomp>{  )    ???!A-11A???r<   c                 >    g | ]}t          j        |          r|nd S r  r  r  s     r/   rQ   z0LayoutPlot._compute_gridspec.<locals>.<listcomp>|  r  r<   c                 >    g | ]}t          j        |          r|nd S r  r  r  s     r/   rQ   z0LayoutPlot._compute_gridspec.<locals>.<listcomp>~  s)    AAAA"+a../QQaAAAr<   c                 J    g | ] }t          j        |          rd |z  dz  nd!S )r$   rH   r  )rO   r   s     r/   rQ   z0LayoutPlot._compute_gridspec.<locals>.<listcomp>  s1    VVVr{1~~<QqS!GG1VVVr<   rR   )width_ratiosheight_ratioswspacehspacer8  c                 B    g | ]}|                     |          fS r:   r4  r5  s     r/   rQ   z0LayoutPlot._compute_gridspec.<locals>.<listcomp>  r7  r<   )r$   r$   )r   r$   )r$   r   r  )r   r   )createc                     | S r3   r:   r  s    r/   r  z.LayoutPlot._compute_gridspec.<locals>.<lambda>  s    Q r<   z is empty, skipping subplot.c                 X    g | ]&\  }}t          j        j        |         |           'S )ro   )r`   r   gs)rO   indprojr5   s      r/   rQ   z0LayoutPlot._compute_gridspec.<locals>.<listcomp>  sB     < < <$3 {473<DAAA < < <r<   )numc              3   B   K   | ]}t          |          t          u V  d S r3   )rK  r  )rO   ps     r/   r   z/LayoutPlot._compute_gridspec.<locals>.<genexpr>  s-      WWADGGx/WWWWWWr<   )w_padh_padrect)C
grid_itemsrY   r   r  coordsrG  	transposer   r   r   r  r   lastrL  rM  r   r   r  nanaspect_weightrK  r>   r   r  r  appendr  r   arrayr  r%   sumabsolute_scalingnanmaxrZ   r[   r\   rf   rx   r   r  r  vspacer  clftightrI  r:  r   rH  r   r,   r  r  r!  grid_situater   r$  r   r   warningr  r   r   tight_paddingtight_layoutrs   )@r5   r   layout_itemslayout_dimensionslayoutscol_widthratiosrow_heightratiosr}   rY  _r[  layout_viewlayout_lensr  r  main_optionseleltype	plot_typeratior  r  layout_shapeprev_heightsprev_widths
col_splits
row_splitswidthswr_unnormalizedhr_listwr_listr  r  r  yscalexinchesyinchesgidxlayout_countr	  rX  r   layout_subplotslayout_axeswsplitshsplits	positionsprojsgsinds
layout_keyobjemptyr"  subplot_datar   adjoint_layoutplotoptslayout_plotwpadhpadr  r6  r  r  s@   ``                                                           @@@r/   r  zLayoutPlot._compute_gridspec  s
    ((**,6vx,H,HRFLLd,.)k ?	7 ?	7FQ"&&'K1vvaV\ZZGAt$)) U#$STTT",T="A"A\$$}VZU[G\G\K)GQFO &8<<K%c+&6&67K #D *4 9 9C499tDHLT4..tV<<DDRTL %J|'7'7!'D'DcJJ %(24(?(?bbff\EUEUV^`aEbEb"0<q@ASS f000 __Wd33b *&G$555 ' 1$r(( ;I!7	8M!MNE$%qw<LL$%q6LL !s+6BKBFJ999 __UD11b +&G$555 ' 1$r(( ;I!7	8M!MNE%&uWaLMM%&FMM!"kCd+<== RPPPP<PPP Q Q Q Q= Q Q Q--s=/A/ABL
 ,//Ar7;;LAa00'3AQ&H #Q"))-888)--a!R99KAQ//&21o{1~%F"Aq!((6666 IH/D/D/F/F(G(GHHH
JJ0@0F0F0H0H)I)IJJJ
 A A(>(>(@(@ A A A B BBCD )%@@ !122 11 \\3w<<d @?w?????w???AAAAABBsVVoVVVWWW  	,")F+++E%$/E4=99 	2o-GfnGG_Q'oa(61Goa(GG_Q'oa(Goa(61G 	Dw 	DL//'0BCCC#D$1829+/;+/;	8 8 8 	U!!! 
!<<Efi<HH**64>> $;ty!}}$) 5 5 5 5 5 5/35 5 5 6 6')2K ;	> ;	>DAq mG mG!U**&7#u,,$7#u,,-7#u,,& Aq6?D)5kBI //A04l5 0 R RKAq%,,T;EELD&(,,aV\BBMJ&(++ M
 M$(->
)K)K$L$L! 1a&/Csx//Ey  "#B'']];;	:: "
""ch#L#L#LMMM " !$)QqS 1!< < < <(+FE(:(:< < <G00i1BL15c)W6M6M1N1N:?5QQQ\ 1 S SL +7'Hna")KA **488@H+NKRZ Q Q04U0CQGOQ QK&1OQF#WW9M9T9T9V9VWWWWWWa\aE >/= ,  	W$,udm<< S!/
dT666T%7t?QRRR DG e!4VV4?VgVVV-===r<   c                     |dk    r	|dz   |g}}n|dk    r|dz   ||dz   g}}||z   }|dk    r|dz   |z  dk    }|r|n|dz   }|||g}}n)|dk    r#|dz   |z  dk    }|r|n|dz   }|||dz   ||dz   g}}||fS )a@  
        Situate the current AdjointLayoutPlot in a LayoutPlot. The
        LayoutPlot specifies a layout_type into which the AdjointLayoutPlot
        must be embedded. This enclosing layout is guaranteed to have
        enough cells to display all the views.

        Based on this enforced layout format, a starting index
        supplied by LayoutPlot (indexing into a large gridspec
        arrangement) is updated to the appropriate embedded value. It
        will also return a list of gridspec indices associated with
        the all the required layout axes.
        r  r$   r  r   r  r   r  r:   )	r5   current_idxr  subgrid_widthr   inds
bottom_idxrk   grid_idxs	            r/   r
  zLayoutPlot.grid_situate  s     (""%a-+4EEF""%a-+{1})E4E =0
/))"1}5!;F&,=

+q@H"[*$=4EEH$$"1}5!;F&,=

+BH"[+a-(*Q,%84E d{r<   r$   c                    |i }i }g }	|                     d|j                  }
t          d|          }|D ]}|                    |d          }t	          |          st          |          }|                    |d          }||                    d t          g          s|	                    d           |	                    | 	                    |                     |s| 
                    |d          j        }i }i }|dk    r:| j                            d	                                          }d
 |D             }nH|dk    rt          dd          }t          |fi |}n#|dk    rt          d          }t          |fi |}t          |fi |}|                    || j        d                    t#          |t$                    r|j        n|j        }t#          |t*                    r|du|d<   t,          j        d         |         }|dk    r |t0          j        v rt0          j        |         }t5          | j                  dk    r|nd} ||f|| j        | j        ||d| j        || j        d	|||<   t#          |t          t$          t@          tB          f          r||         j"        |
|<   ||         j#        |
|<   ||
|	fS )r  NFr8  )r   r   c                     | S r3   r:   r  s    r/   r  z-LayoutPlot._create_subplots.<locals>.<lambda>#  s    1 r<   r=  r  T)onlychangedc                 "    i | ]\  }}d |v 	||S )	sublabel_r:   )rO   r   r   s      r/   r  z/LayoutPlot._create_subplots.<locals>.<dictcomp>5  s2     !6 !6 !6$!Q$/1$4$4 "#A$4$4$4r<   rl   )invert_axesr?  rm   )r@  rR   )rR   r%  r?   r$   r   )	rS   r   r   r  r   r   rD  r   r^   )$rI  r:  r,   rG  r#   r"   r$  r   r  rN  rL  rM  r   r  r   r+   rf   rY   r   rK  rh   r   r   rT  r>   r   r   r  r   r   rD  r^   r   r   r  r   )r5   r   r-  r  r   axesr  r  r   projectionsadjoint_clonesubplot_optsr  r[  r  r5  override_optssublabel_opts
own_params
right_optstop_optsr\  r  s                          r/   r!  zLayoutPlot._create_subplots  s0    <D69EEuv>>> 5	: 5	:C::c4((Dt$$ %t}}#t$$B|4==wi#H#H|""4((( t33D99:::  **488@H MMf}}!Z..4.@@FFHH
!6 !6* !6 !6 !6!d(,. . .
 $\ @ @Z @ @d+++ $\ > >X > > M66X66HOOMt|E/BOCCC!+D'!:!:NDIIE$	** 9*,D.'|4U;If}}'*;!;!;#-e4	T[))A--##1C%Id J$)158I-3T.2ls/3}J J
 AIJ JHSM $'8=M NOO :%-c]%7c""%-c]%9c""33r<   c           
         | j         d         }|                     | j        |d           }| j                                        D ]}|                    |           d }|                     |          }| j        rft          | j	                  dk    rN|rL | j
        d         j        |fi |                     d          }|| j
        d<   | j
        dxx         |gz  cc<   | j
        d         }|                     t          g          s't          | j        t"                    s| j        rd }t'          t)          j        d	 |                     |          D                                 }t-          || j        | j        ||| j        | j        z  | j        | j        z  
           |                     d g          }	|	D ]}
|
j        r|
                    d            |                     t<          g          }|D ]0}t          |j                  dk    r|                    d           1|                      d           S )Nra  r   r$   rR   r   rT   )specsc                 8    | j                             dd           S )NrT   )rf   rG  r  s    r/   r  z,LayoutPlot.initialize_plot.<locals>.<lambda>h  s    AIMM2F$M$M r<   c              3      K   | ]}||V  	d S r3   r:   )rO   artistss     r/   r   z-LayoutPlot.initialize_plot.<locals>.<genexpr>j  s3       $< $<'.': %,':':':':$< $<r<   )r  r  c                 "    t          | d          S )Ncolorbar)hasattrr  s    r/   r  z,LayoutPlot.initialize_plot.<locals>.<lambda>q  s    wq*7M7M r<   F)r  )!r   r   r   r   r  r   r   r   r   r  rf   suptitler   r$  r  rY   rZ   r[   v17_layout_formatr\   r   from_iterabler&   r  r  r  rN   r  rT  _draw_colorbarr  r  r   )r5   r   r   r   	title_objr   rR   traverse_fnextra_artists	colorbars	cbar_plot	adjoinedsr   s                r/   r   zLayoutPlot.initialize_plotV  s{   im$$T[#t<<}++-- 	3 	3G##6#2222 	""3''? 	>s4;//!3334U+4UVVdnnW>U>UVVI$-DL!L-...9+=...l5!XJ// 	<
4?TY8Z8Z 	<&	<MMK # $< $<4==;U;U $< $< $< < < M sDIty -"k$.8"k$.8: : : : -M-M,NOOI& ; ;	% ;,,E,:::->,?@@I% < <x())A----U-;;;""4(((r<   r3   )Nr$   T)r   r   r   r   r   r  r  r   r  r   rs   r   r	  r   r  r  r  fontsizerW  rW   r  r
  r!  r;   r   r   r   s   @r/   r  r    s        
 ,u+E @3 4 4 4
 !EL 1/ 0 0 0M $#,D K   J
 EM% .   E $EOA 4N O O OM U\# ,K L L LF U\# ,K L L LF u|EEEH 0 0 0 0 0 0Q> Q> Q>f  BD4 D4 D4 D4N ") ") ^") ") ") ") ")r<   r  c                       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
          Z ej	        dd          ZdS )r  rq   zb
        Aspect ratios on SideHistogramPlot should be determined by the
        AdjointLayoutPlot.r@   )r$   r$   r$   r   z(
        Make plot background invisible.r  zI
        The size of the border expressed as a fraction of the main plot.FzE
        Titles should be disabled on all SidePlots to avoid clutter.zG
        The size subplots as expressed as a fraction of the main plot.z
        Whether to show the x-label of the plot. Disabled by default
        because plots are often too cramped to fit the title correctly.N)r   r   r   r   r   rf  bgcolorr   r  r   r   r  show_xlabelr:   r<   r/   r  r  }  s        U_V 2   F eol 9+ , , ,G %,t 2L M M MK u 3H I I IJ  5< 3J K K KL  %- 4K L L LKKKr<   r  )9
contextlibr   	itertoolsr   r?   r)   numpyr  r   r   r   r   r`   r   matplotlib.font_managerr	   mpl_toolkits.mplot3dr
   corer   r   r   r   r   r   r   r   r   r   core.optionsr   r   	core.utilr   r   r   r=  r   r   r   r   r    utilr!   r"   r#   r%   r&   r'   r0   r;   r>   r   r  r  r  r  r:   r<   r/   <module>rm     sP   % % % % % %                           2 1 1 1 1 1 ' ' ' ' ' '                        1 0 0 0 0 0 0 0 G G G G G G G G G G              8 7 7 7 7 7 7 7 7 7 > > > > > > > > > > * * *  P% P% P% P% P%o P% P% P%h&  &  &  &  & (' &  &  & T~: ~: ~: ~: ~:} ~: ~: ~:D
fD fD fD fD fD!9 fD fD fDRN) N) N) N) N)"M N) N) N)dL L L L L? L L L L Lr<   