
    h*                       S r SSKJr  SSKrSSKrSSKrSSKrSSKJr  SSK	r	SSK
rSSKrSSKJrJrJrJr  SSKJrJrJr  SSKJrJrJrJrJr  SSKJr  SSKJr  SSK J!r"  SSK#J$r%  SSK&J'r'  SS	K(J)r)J*r*  SS
K+J,r,J-r-J.r.J/r/  SSK0J1r2  SSK3J4r4  SSK5J6r6  SSK7J8r8J9r9J:r:J;r;  \Rx                  " \=5      r>S r? " S S5      r@ " S S\5      rA\R                   " S S\A5      5       rC\R                   " S S\A5      5       rDS rEg)a  
`matplotlib.figure` implements the following classes:

`Figure`
    Top level `~matplotlib.artist.Artist`, which holds all plot elements.
    Many methods are implemented in `FigureBase`.

`SubFigure`
    A logical figure inside a figure, usually added to a figure (or parent `SubFigure`)
    with `Figure.add_subfigure` or `Figure.subfigures` methods.

Figures are typically created using pyplot methods `~.pyplot.figure`,
`~.pyplot.subplots`, and `~.pyplot.subplot_mosaic`.

.. plot::
    :include-source:

    fig, ax = plt.subplots(figsize=(2, 2), facecolor='lightskyblue',
                           layout='constrained')
    fig.suptitle('Figure')
    ax.set_title('Axes', loc='left', fontstyle='oblique', fontsize='medium')

Some situations call for directly instantiating a `~.figure.Figure` class,
usually inside an application of some sort (see :ref:`user_interfaces` for a
list of examples) .  More information about Figures can be found at
:ref:`figure-intro`.
    )	ExitStackN)Integral)_blocking_inputbackend_bases
_docstringprojections)Artistallow_rasterization_finalize_rasterization)	DrawEventFigureCanvasBaseNonGuiExceptionMouseButton_get_renderer)Axes)GridSpecSubplotParams)ConstrainedLayoutEngineTightLayoutEngineLayoutEnginePlaceHolderLayoutEngine)	Rectangle)Text)Affine2DBboxBboxTransformToTransformedBboxc                 6    U R                  SS9=nb  Xl        g g )NFroot)
get_figurestale)selfvalfigs      C/var/www/html/env/lib/python3.13/site-packages/matplotlib/figure.py_stale_figure_callbackr'   A   s"    E**7	 8    c                   H    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rSrg)
_AxesStackF   z
Helper class to track Axes in a figure.

Axes are tracked both in the order in which they have been added
(``self._axes`` insertion/iteration order) and in the separate "gca" stack
(which is the index to which they map in the ``self._axes`` dict).
c                 F    0 U l         [        R                  " 5       U l        g N)_axes	itertoolscount_counterr#   s    r&   __init___AxesStack.__init__O   s    
!)r(   c                     / U R                   Q$ )z1List the Axes that have been added to the figure.)r.   r2   s    r&   as_list_AxesStack.as_listS   s    }r(   c                 :    U R                   R                  U5        g)zRemove the Axes from the stack.N)r.   popr#   as     r&   remove_AxesStack.removeW   s    

qr(   c                 |    XR                   ;  a  [        S5      e[        U R                  5      U R                   U'   g)z@Move an Axes, which must already exist in the stack, to the top.zAxes has not been added yetN)r.   
ValueErrornextr1   r:   s     r&   bubble_AxesStack.bubble[   s.    JJ:;;T]]+

1r(   c                 h    XR                   ;  a#  [        U R                  5      U R                   U'   gg)z9Add an Axes to the stack, ignoring it if already present.N)r.   r@   r1   r:   s     r&   add_AxesStack.adda   s'    JJ /DJJqM r(   c                 T    [        U R                  U R                  R                  SS9$ )z6Return the active Axes, or None if the stack is empty.N)keydefault)maxr.   __getitem__r2   s    r&   current_AxesStack.currentf   s    4::4::#9#94HHr(   c                 d    0 [        U 5      ES[        U R                  R                  5       SS90E$ )Nr1   r   )rH   )varsrI   r.   valuesr2   s    r&   __getstate___AxesStack.__getstate__j   s6    
4j
DJJ--/;
 	
r(   c                     UR                  S5      n[        U 5      R                  U5        [        R                  " U5      U l        g )Nr1   )r9   rN   updater/   r0   r1   )r#   statenext_counters      r&   __setstate___AxesStack.__setstate__p   s2    yy,T
% !5r(   )r.   r1   N)__name__
__module____qualname____firstlineno____doc__r3   r6   r<   rA   rD   rK   rP   rV   __static_attributes__ r(   r&   r*   r*   F   s0    *,0
I
6r(   r*   c            	         ^  \ rS rSrSrU 4S jrS r SRS jrS rSSS jr	S	 r
\" \R                  " \	S
S9\
SS9rS rSSS jrS r\R&                  " SSSSSSS9\R(                  " \5      S 5       5       rS r\R&                  " SSSSSSS9\R(                  " \5      S 5       5       rS r\R&                  " S SS!S"SSS9\R(                  " \5      S# 5       5       rS$ rS% rS& rS' rS( rS) rS* r S+ r!S, r"\" \\"5      r#STS. jr$\RJ                  S/ 5       r&\RJ                  S0 5       r'S1 r(SUS-S-S
SSSSS2.S3 jjr)S4 r*S5 r+STS6 jr,STS7 jr-\RJ                  S8 5       r.\RJ                  SSS9 j5       r/\RJ                   SVS: j5       r0  SWS; jr1SSS< jr2SSS= jr3SSS> jr4SSS? jr5SUS@ jr6   SXSA jr7SB r8SC r9SD r:SE r;SS-SSF.SG jr<SH r=SSSSI.SJ jjr>\?SK 5       r@\?SL 5       rAS-S-SSSMSSSSN.SO jrBSP rCSQrDU =rE$ )Y
FigureBasev   z
Base class for `.Figure` and `.SubFigure` containing the methods that add
artists to the figure or subfigure, create Axes, etc.
c                   > [         TU ]  5         U ?S U l        S U l        S U l        [        R                  " 5       [        R                  " 5       [        R                  " 5       S.U l        / U l	        / U l
        / U l        / U l        / U l        / U l        / U l        / U l        SU l        S U l        U R&                  " S0 UD6  g )N)xytitleTr^   )superr3   r.   	_suptitle
_supxlabel
_supylabelcbookGrouper_align_label_groups
_localaxesartistslinespatchestextsimageslegendssubfigsr"   suppressCompositeset)r#   kwargs	__class__s     r&   r3   FigureBase.__init__{   s    
 J ]]_$
  


!%6r(   c                    U R                  5       nUR                  U R                  5        [        S U 5       S S9nU R                   H  nUR                  5       nUR                  U(       a  U" X15      OS5        UR                  5        HF  n[        US5      (       d  M  UR                  5       nUR                  U(       a  U" XQ5      OS5        MH     M     U$ )zAlso runs apply_aspectc              3   R   #    U  H  oR                  5       (       a  M  Uv   M     g 7fr-   )get_animated).0artists     r&   	<genexpr>/FigureBase._get_draw_artists.<locals>.<genexpr>   s     G'1D1D1FVV's   '	'c                 "    U R                  5       $ r-   )
get_zorder)r~   s    r&   <lambda>.FigureBase._get_draw_artists.<locals>.<lambda>   s    v002r(   )rG   Napply_aspect)get_childrenr<   patchsortedrm   get_axes_locatorr   hasattr)r#   rendererrn   axlocatorchilds         r&   _get_draw_artistsFigureBase._get_draw_artists   s    ##%tzz"G'G24 //B))+GOOWGB1$G*5.11#446G&&4;0G +	 " r(   c                 0   [         R                  " / SQUS9  U R                   Vs/ s H  oUR                  S:w  d  M  UPM     nn[	        S U 5       5      n[        U5      S:X  aF  U R                  S   R                  US9 H%  nUR                  U5        UR                  U5        M'     OU(       a  U H  nUR                  5       R                  5       (       a:  UR                  US9 H%  nUR                  U5        UR                  U5        M'     M`  UR                  US9 H  nUR                  S5        M     UR                  S5        M     U R                  5       n	U(       a#  U	b  U	R                  (       a  U R                  US
9  SU l        g	s  snf )a  
Date ticklabels often overlap, so it is useful to rotate them
and right align them.  Also, a common use case is a number of
subplots with shared x-axis where the x-axis is date data.  The
ticklabels are often long, and it helps to rotate them on the
bottom subplot and turn them off on other subplots, as well as
turn off xlabels.

Parameters
----------
bottom : float, default: 0.2
    The bottom of the subplots for `subplots_adjust`.
rotation : float, default: 30 degrees
    The rotation angle of the xtick labels in degrees.
ha : {'left', 'center', 'right'}, default: 'right'
    The horizontal alignment of the xticklabels.
which : {'major', 'minor', 'both'}, default: 'major'
    Selects which ticklabels to rotate.
)majorminorboth)whichz
<colorbar>c              3   @   #    U  H  oR                  5       v   M     g 7fr-   )get_subplotspec)r}   r   s     r&   r   +FigureBase.autofmt_xdate.<locals>.<genexpr>   s     >2,,..s      r   F N)bottomT)_apicheck_in_listaxes_labelalllenget_xticklabelsset_haset_rotationr   is_last_rowset_visible
set_xlabelget_layout_engineadjust_compatiblesubplots_adjustr"   )
r#   r   rotationhar   r   r   allsubplotslabelengines
             r&   autofmt_xdateFigureBase.autofmt_xdate   sX   * 	5UC!YYDYr))|*CYD>>>t9>155E5BR ""8, C B))+7799%'%7%7e%7%DE!LL,!..x8 &E &(%7%7e%7%DE!--e4 &Eb)  '')FNf.F.F   /
+ Es
   FFc                     U R                   /U R                  QU R                  QU R                  QU R                  QU R
                  QU R                  QU R                  QU R                  Q$ )z.Get a list of artists contained in the figure.)	r   rn   rm   ro   rp   rq   rr   rs   rt   r2   s    r&   r   FigureBase.get_children   s    

   	
     	r(   Nc                     U R                   U L a  U $ U R                  U R                   L a  U R                  $ Uc  Sn[        R                  " SUS9  SnU(       a  U R                   $ U R                  $ )aM  
Return the `.Figure` or `.SubFigure` instance the (Sub)Figure belongs to.

Parameters
----------
root : bool, default=True
    If False, return the (Sub)Figure this artist is on.  If True,
    return the root Figure for a nested tree of SubFigures.

    .. deprecated:: 3.10

        From version 3.12 *root* will default to False.
zFrom Matplotlib 3.12 SubFigure.get_figure will by default return the direct parent figure, which may be a SubFigure. To suppress this warning, pass the root parameter.  Pass `True` to maintain the old behavior and `False` to opt-in to the future behavior.3.10messageT)_root_figure_parentr   warn_deprecated)r#   r    r   s      r&   r!   FigureBase.get_figure   sq     $K<<4,,, <<<.G
   9D$$$||r(   c                 j    SnXR                   L a  [        R                  " SU S3S9  g[        U5      e)z
.. deprecated:: 3.10
    Currently this method will raise an exception if *fig* is anything other
    than the root `.Figure` this (Sub)Figure is on.  In future it will always
    raise an exception.
z\The parent and root figures of a (Sub)Figure are set at instantiation and cannot be changed.r   z= From Matplotlib 3.12 this operation will raise an exception.r   N)r   r   r   r?   )r#   r%   	no_switchs      r&   
set_figureFigureBase.set_figure  sE    <	###  %; ') )+ ##r(   Tr   zTThe root `Figure`.  To get the parent of a `SubFigure`, use the `get_figure` method.docc                     U R                  U5      (       a  S0 4$ U R                  R                  UR                  UR                  5      nU0 4$ )zT
Test whether the mouse event occurred on the figure.

Returns
-------
    bool, {}
F)_different_canvasbboxcontainsrc   rd   )r#   
mouseeventinsides      r&   r   FigureBase.contains%  sG     !!*--"9##JLL*,,?rzr(   c                     U R                   $ r-   r   r#   r   s     r&   get_window_extentFigureBase.get_window_extent2  s    yyr(   c                    UR                  SS5      nUR                  SS5      nUS   S;   a  USL nOUS   S:X  a  USL nUc  US   nUc  US   n[        R                  " U[        5      nUR	                  S	US
   5        UR	                  SUS   5        UR	                  SUS   5        SU;  aL  UR	                  S[
        R                  US      5        UR	                  S[
        R                  US      5        [        XS   5      nUb6  UR                  U5        UR                  XE45        UR                  " S0 UD6  O#U R                  " XEU40 UD6n[        XS   U5        WUl        SU l        U$ )a  
Add a centered %(name)s to the figure.

Parameters
----------
t : str
    The %(name)s text.
x : float, default: %(x0)s
    The x location of the text in figure coordinates.
y : float, default: %(y0)s
    The y location of the text in figure coordinates.
horizontalalignment, ha : {'center', 'left', 'right'}, default: %(ha)s
    The horizontal alignment of the text relative to (*x*, *y*).
verticalalignment, va : {'top', 'center', 'bottom', 'baseline'}, default: %(va)s
    The vertical alignment of the text relative to (*x*, *y*).
fontsize, size : default: :rc:`figure.%(rc)ssize`
    The font size of the text. See `.Text.set_size` for possible
    values.
fontweight, weight : default: :rc:`figure.%(rc)sweight`
    The font weight of the text. See `.Text.set_weight` for possible
    values.

Returns
-------
text
    The `.Text` instance of the %(name)s.

Other Parameters
----------------
fontproperties : None or dict, optional
    A dict of font properties. If *fontproperties* is given the
    default values for font size and weight are taken from the
    `.FontProperties` defaults. :rc:`figure.%(rc)ssize` and
    :rc:`figure.%(rc)sweight` are ignored in this case.

**kwargs
    Additional kwargs are `matplotlib.text.Text` properties.
rc   Nrd   name)rh   rg   ri   x0y0horizontalalignmentr   verticalalignmentvar   fontpropertiesfontsizesize
fontweightweightTr^   )r9   rj   normalize_kwargsr   
setdefaultmplrcParamsgetattrset_textset_positionrv   textsetattr_autoposr"   )r#   tinforw   rc   rd   autopossuplabs           r&   
_suplabelsFigureBase._suplabels6  st   R JJsD!JJsD!<664iG&\\)4iG9T
A9T
A''5/d<-tDz:*d:&676)j#,,tF|*DElCLLh,HIF|,OOA'JJ  YYqQ1&1FDv,/!
r(         ?\(\?zsuper titlecentertopre   )r   r   r   r   r   rcc           	      >    SSSSSSSSS	.nU R                   " X40 UD6$ )
Nrg   r   r   r   r   r   zfigure.titlesizezfigure.titleweightr   r   r   r   r   r   r   r   r   r#   r   rw   r   s       r&   suptitleFigureBase.suptitle  s6    
 $3de*6JL q1&11r(   c                 D    U R                   nUc  S$ UR                  5       $ )z<Return the suptitle as string or an empty string if not set.r   )rg   get_textr#   text_objs     r&   get_suptitleFigureBase.get_suptitle  s$    >>%r>8+<+<+>>r(   {Gz?zsuper xlabelr   r   c           	      >    SSSSSSSSS	.nU R                   " X40 UD6$ )
Nrh   r   r   r   r   r   figure.labelsizefigure.labelweightr   r   r   s       r&   	supxlabelFigureBase.supxlabel  s6    
 %CthA*6JL q1&11r(   c                 D    U R                   nUc  S$ UR                  5       $ )z=Return the supxlabel as string or an empty string if not set.r   )rh   r   r   s     r&   get_supxlabelFigureBase.get_supxlabel  $    ??%r>8+<+<+>>r(   {Gz?zsuper ylabelleftc           
      @    SSSSSSSSS	S
.	nU R                   " X40 UD6$ )Nri   r  r   r  r   verticalanchorr   r   )	r   r   r   r   r   r   rotation_moder   r   r   r   s       r&   	supylabelFigureBase.supylabel  s8    
 %DH*!)3E.0 q1&11r(   c                 D    U R                   nUc  S$ UR                  5       $ )z=Return the supylabel as string or an empty string if not set.r   )ri   r   r   s     r&   get_supylabelFigureBase.get_supylabel  r  r(   c                 6    U R                   R                  5       $ )z+Get the edge color of the Figure rectangle.)r   get_edgecolorr2   s    r&   r  FigureBase.get_edgecolor      zz''))r(   c                 6    U R                   R                  5       $ )z+Get the face color of the Figure rectangle.)r   get_facecolorr2   s    r&   r  FigureBase.get_facecolor  r  r(   c                 6    U R                   R                  5       $ )z
Return the figure's background patch visibility, i.e.
whether the figure background will be drawn. Equivalent to
``Figure.patch.get_visible()``.
)r   get_visibler2   s    r&   get_frameonFigureBase.get_frameon  s     zz%%''r(   c                 :    U R                   R                  U5        g)zW
Set the line width of the Figure rectangle.

Parameters
----------
linewidth : number
N)r   set_linewidth)r#   	linewidths     r&   r  FigureBase.set_linewidth  s     	

  +r(   c                 6    U R                   R                  5       $ )z-
Get the line width of the Figure rectangle.
)r   get_linewidthr2   s    r&   r   FigureBase.get_linewidth  s     zz''))r(   c                 :    U R                   R                  U5        g)z]
Set the edge color of the Figure rectangle.

Parameters
----------
color : :mpltype:`color`
N)r   set_edgecolorr#   colors     r&   r#  FigureBase.set_edgecolor       	

  'r(   c                 :    U R                   R                  U5        g)z]
Set the face color of the Figure rectangle.

Parameters
----------
color : :mpltype:`color`
N)r   set_facecolorr$  s     r&   r)  FigureBase.set_facecolor  r'  r(   c                 H    U R                   R                  U5        SU l        g)z
Set the figure's background patch visibility, i.e.
whether the figure background will be drawn. Equivalent to
``Figure.patch.set_visible()``.

Parameters
----------
b : bool
TN)r   r   r"   )r#   bs     r&   set_frameonFigureBase.set_frameon  s     	

q!
r(   Fc                 h   UR                  U 5        U R                  R                  U5        U R                  R                  Ul        UR                  5       (       d  UR                  U R                  5        U(       a,  UR                  5       c  UR                  U R                  5        SU l        U$ )aQ  
Add an `.Artist` to the figure.

Usually artists are added to `~.axes.Axes` objects using
`.Axes.add_artist`; this method can be used in the rare cases where
one needs to add artists directly to the figure instead.

Parameters
----------
artist : `~matplotlib.artist.Artist`
    The artist to add to the figure. If the added artist has no
    transform previously set, its transform will be set to
    ``figure.transSubfigure``.
clip : bool, default: False
    Whether the added artist should be clipped by the figure patch.

Returns
-------
`~matplotlib.artist.Artist`
    The added artist.
T)r   rn   appendr<   _remove_methodis_transform_setset_transformtransSubfigureget_clip_pathset_clip_pathr   r"   )r#   r~   clips      r&   
add_artistFigureBase.add_artist  s    , 	$F# $ 3 3&&((  !4!45F((*2  ,
r(   c                 n   [        U5      (       d  SU;  a  [        S5      eSU;   a-  [        U5      (       a  [        S5      eUR                  S5      4n[        U5      S:w  a!  [        R                  " SS[        U5      5      e[        US   [        5      (       a.  Uu  nUR                  nUR                  SS9U La  [        S	5      eO[Uu  n[        R                  " U5      R                  5       (       d  [        S
U 35      eU R                  " S0 UD6u  pgU" X40 UD6nXg4nU R                  X45      $ )aT	  
Add an `~.axes.Axes` to the figure.

Call signatures::

    add_axes(rect, projection=None, polar=False, **kwargs)
    add_axes(ax)

Parameters
----------
rect : tuple (left, bottom, width, height)
    The dimensions (left, bottom, width, height) of the new
    `~.axes.Axes`. All quantities are in fractions of figure width and
    height.

projection : {None, 'aitoff', 'hammer', 'lambert', 'mollweide', 'polar', 'rectilinear', str}, optional
    The projection type of the `~.axes.Axes`. *str* is the name of
    a custom projection, see `~matplotlib.projections`. The default
    None results in a 'rectilinear' projection.

polar : bool, default: False
    If True, equivalent to projection='polar'.

axes_class : subclass type of `~.axes.Axes`, optional
    The `.axes.Axes` subclass that is instantiated.  This parameter
    is incompatible with *projection* and *polar*.  See
    :ref:`axisartist_users-guide-index` for examples.

sharex, sharey : `~matplotlib.axes.Axes`, optional
    Share the x or y `~matplotlib.axis` with sharex and/or sharey.
    The axis will have the same limits, ticks, and scale as the axis
    of the shared Axes.

label : str
    A label for the returned Axes.

Returns
-------
`~.axes.Axes`, or a subclass of `~.axes.Axes`
    The returned Axes class depends on the projection used. It is
    `~.axes.Axes` if rectilinear projection is used and
    `.projections.polar.PolarAxes` if polar projection is used.

Other Parameters
----------------
**kwargs
    This method also takes the keyword arguments for
    the returned Axes class. The keyword arguments for the
    rectilinear Axes class `~.axes.Axes` can be found in
    the following table but there might also be other keyword
    arguments if another projection is used, see the actual Axes
    class.

    %(Axes:kwdoc)s

Notes
-----
In rare circumstances, `.add_axes` may be called with a single
argument, an Axes instance already created in the present figure but
not in the figure's list of Axes.

See Also
--------
.Figure.add_subplot
.pyplot.subplot
.pyplot.axes
.Figure.subplots
.pyplot.subplots

Examples
--------
Some simple examples::

    rect = l, b, w, h
    fig = plt.figure()
    fig.add_axes(rect)
    fig.add_axes(rect, frameon=False, facecolor='g')
    fig.add_axes(rect, polar=True)
    ax = fig.add_axes(rect, projection='polar')
    fig.delaxes(ax)
    fig.add_axes(ax)
rectz9add_axes() missing 1 required positional argument: 'rect'z2add_axes() got multiple values for argument 'rect'r   add_axesr   Fr   5The Axes must have been created in the present figurez'all entries in rect must be finite not r^   )r   	TypeErrorr9   r   nargs_error
isinstancer   _projection_initr!   r?   npisfiniter    _process_projection_requirements_add_axes_internal)r#   argsrw   r;   rG   r;  projection_classpkws           r&   r<  FigureBase.add_axes  s5   l 4yyV61WXXv4yy TUUJJv&)Dt9>"":q#d)<<d1gt$$BA$$C|||'t3 KM M 4 ED;;t$((** #J4&!QRR$($I$I$SF$S! !3s3A#)C&&q..r(   c           	         SU;   a  [         R                  " SS5      e[        U5      S:X  a}  [        US   [        R
                  R                  R                  5      (       aG  US   R                  5       (       a/  US   nUR                  nUR                  SS9U La  [        S5      eOU(       d  Sn[        U5      S:X  aP  [        US   [        5      (       a8  S	US   s=::  a  S
::  a(  O  O%[        [        [        [!        US   5      5      5      nU R"                  " S0 UD6u  pVU" U /UQ70 UD6nXV4nU R%                  X45      $ )a  
Add an `~.axes.Axes` to the figure as part of a subplot arrangement.

Call signatures::

   add_subplot(nrows, ncols, index, **kwargs)
   add_subplot(pos, **kwargs)
   add_subplot(ax)
   add_subplot()

Parameters
----------
*args : int, (int, int, *index*), or `.SubplotSpec`, default: (1, 1, 1)
    The position of the subplot described by one of

    - Three integers (*nrows*, *ncols*, *index*). The subplot will
      take the *index* position on a grid with *nrows* rows and
      *ncols* columns. *index* starts at 1 in the upper left corner
      and increases to the right.  *index* can also be a two-tuple
      specifying the (*first*, *last*) indices (1-based, and including
      *last*) of the subplot, e.g., ``fig.add_subplot(3, 1, (1, 2))``
      makes a subplot that spans the upper 2/3 of the figure.
    - A 3-digit integer. The digits are interpreted as if given
      separately as three single-digit integers, i.e.
      ``fig.add_subplot(235)`` is the same as
      ``fig.add_subplot(2, 3, 5)``. Note that this can only be used
      if there are no more than 9 subplots.
    - A `.SubplotSpec`.

    In rare circumstances, `.add_subplot` may be called with a single
    argument, a subplot Axes instance already created in the
    present figure but not in the figure's list of Axes.

projection : {None, 'aitoff', 'hammer', 'lambert', 'mollweide', 'polar', 'rectilinear', str}, optional
    The projection type of the subplot (`~.axes.Axes`). *str* is the
    name of a custom projection, see `~matplotlib.projections`. The
    default None results in a 'rectilinear' projection.

polar : bool, default: False
    If True, equivalent to projection='polar'.

axes_class : subclass type of `~.axes.Axes`, optional
    The `.axes.Axes` subclass that is instantiated.  This parameter
    is incompatible with *projection* and *polar*.  See
    :ref:`axisartist_users-guide-index` for examples.

sharex, sharey : `~matplotlib.axes.Axes`, optional
    Share the x or y `~matplotlib.axis` with sharex and/or sharey.
    The axis will have the same limits, ticks, and scale as the axis
    of the shared Axes.

label : str
    A label for the returned Axes.

Returns
-------
`~.axes.Axes`

    The Axes of the subplot. The returned Axes can actually be an
    instance of a subclass, such as `.projections.polar.PolarAxes` for
    polar projections.

Other Parameters
----------------
**kwargs
    This method also takes the keyword arguments for the returned Axes
    base class; except for the *figure* argument. The keyword arguments
    for the rectilinear base class `~.axes.Axes` can be found in
    the following table but there might also be other keyword
    arguments if another projection is used.

    %(Axes:kwdoc)s

See Also
--------
.Figure.add_axes
.pyplot.subplot
.pyplot.axes
.Figure.subplots
.pyplot.subplots

Examples
--------
::

    fig = plt.figure()

    fig.add_subplot(231)
    ax1 = fig.add_subplot(2, 3, 1)  # equivalent but more general

    fig.add_subplot(232, frameon=False)  # subplot with no frame
    fig.add_subplot(233, projection='polar')  # polar subplot
    fig.add_subplot(234, sharex=ax1)  # subplot sharing x-axis with ax1
    fig.add_subplot(235, facecolor="red")  # red subplot

    ax1.remove()  # delete ax1 from the figure
    fig.add_subplot(ax1)  # add ax1 back to the figure
figureadd_subplotr   r   Fr   r=  )r   r   r   d   i  r^   )r   kwarg_errorr   r@  r   r   _base	_AxesBaser   rA  r!   r?   r   tuplemapintstrrD  rE  )r#   rF  rw   r   rG   rG  rH  s          r&   rL  FigureBase.add_subplot  s2   J v ""=(;;INtAw(@(@AAG++--aB%%C}}%}(4  "6 7 7 5   D	Q:d1gx#@#@tAw-#-Sc$q'l34$($I$I$SF$S!!$555B#)C&&r//r(   c                    U R                   R                  U5        XR                  ;  a  U R                  R                  U5        U R	                  U5        U R
                  Ul        X!l        SU l        [        Ul
        U$ )z0Private helper for `add_axes` and `add_subplot`.T)_axstackrD   rm   r0  scadelaxesr1  rA  r"   r'   stale_callback)r#   r   rG   s      r&   rE  FigureBase._add_axes_internal  sa    "__$OO""2& LL!
2	r(   )sharexshareysqueezewidth_ratiosheight_ratios
subplot_kwgridspec_kwc                    [        U	=(       d    0 5      n	Ub  SU	;   a  [        S5      eXyS'   Ub  SU	;   a  [        S5      eXiS'   U R                  " X4SU 0U	D6n
U
R                  X4UUS9nU$ )a  
Add a set of subplots to this figure.

This utility wrapper makes it convenient to create common layouts of
subplots in a single call.

Parameters
----------
nrows, ncols : int, default: 1
    Number of rows/columns of the subplot grid.

sharex, sharey : bool or {'none', 'all', 'row', 'col'}, default: False
    Controls sharing of x-axis (*sharex*) or y-axis (*sharey*):

    - True or 'all': x- or y-axis will be shared among all subplots.
    - False or 'none': each subplot x- or y-axis will be independent.
    - 'row': each subplot row will share an x- or y-axis.
    - 'col': each subplot column will share an x- or y-axis.

    When subplots have a shared x-axis along a column, only the x tick
    labels of the bottom subplot are created. Similarly, when subplots
    have a shared y-axis along a row, only the y tick labels of the
    first column subplot are created. To later turn other subplots'
    ticklabels on, use `~matplotlib.axes.Axes.tick_params`.

    When subplots have a shared axis that has units, calling
    `.Axis.set_units` will update each axis with the new units.

    Note that it is not possible to unshare axes.

squeeze : bool, default: True
    - If True, extra dimensions are squeezed out from the returned
      array of Axes:

      - if only one subplot is constructed (nrows=ncols=1), the
        resulting single Axes object is returned as a scalar.
      - for Nx1 or 1xM subplots, the returned object is a 1D numpy
        object array of Axes objects.
      - for NxM, subplots with N>1 and M>1 are returned as a 2D array.

    - If False, no squeezing at all is done: the returned Axes object
      is always a 2D array containing Axes instances, even if it ends
      up being 1x1.

width_ratios : array-like of length *ncols*, optional
    Defines the relative widths of the columns. Each column gets a
    relative width of ``width_ratios[i] / sum(width_ratios)``.
    If not given, all columns will have the same width.  Equivalent
    to ``gridspec_kw={'width_ratios': [...]}``.

height_ratios : array-like of length *nrows*, optional
    Defines the relative heights of the rows. Each row gets a
    relative height of ``height_ratios[i] / sum(height_ratios)``.
    If not given, all rows will have the same height. Equivalent
    to ``gridspec_kw={'height_ratios': [...]}``.

subplot_kw : dict, optional
    Dict with keywords passed to the `.Figure.add_subplot` call used to
    create each subplot.

gridspec_kw : dict, optional
    Dict with keywords passed to the
    `~matplotlib.gridspec.GridSpec` constructor used to create
    the grid the subplots are placed on.

Returns
-------
`~.axes.Axes` or array of Axes
    Either a single `~matplotlib.axes.Axes` object or an array of Axes
    objects if more than one subplot was created. The dimensions of the
    resulting array can be controlled with the *squeeze* keyword, see
    above.

See Also
--------
.pyplot.subplots
.Figure.add_subplot
.pyplot.subplot

Examples
--------
::

    # First create some toy data:
    x = np.linspace(0, 2*np.pi, 400)
    y = np.sin(x**2)

    # Create a figure
    fig = plt.figure()

    # Create a subplot
    ax = fig.subplots()
    ax.plot(x, y)
    ax.set_title('Simple plot')

    # Create two subplots and unpack the output array immediately
    ax1, ax2 = fig.subplots(1, 2, sharey=True)
    ax1.plot(x, y)
    ax1.set_title('Sharing Y axis')
    ax2.scatter(x, y)

    # Create four polar Axes and access them through the returned array
    axes = fig.subplots(2, 2, subplot_kw=dict(projection='polar'))
    axes[0, 0].plot(x, y)
    axes[1, 1].scatter(x, y)

    # Share an X-axis with each column of subplots
    fig.subplots(2, 2, sharex='col')

    # Share a Y-axis with each row of subplots
    fig.subplots(2, 2, sharey='row')

    # Share both X- and Y-axes with all subplots
    fig.subplots(2, 2, sharex='all', sharey='all')

    # Note that this is the same as
    fig.subplots(2, 2, sharex=True, sharey=True)
r`  Q'height_ratios' must not be defined both as parameter and as key in 'gridspec_kw'r_  P'width_ratios' must not be defined both as parameter and as key in 'gridspec_kw'rK  )r\  r]  r^  ra  )dictr?   add_gridspecsubplots)r#   nrowsncolsr\  r]  r^  r_  r`  ra  rb  gsaxss               r&   rh  FigureBase.subplots  s    r ;,"-$+-  "I J J+8(#,  "I J J*6'uHDHKHkk%/  1
r(   c                 N    U R                  XR                  U R                  /S9  g)zI
Remove the `~.axes.Axes` *ax* from the figure; update the current Axes.
)ownersN)_remove_axesrW  rm   r#   r   s     r&   rY  FigureBase.delaxes  s"     	"mmT__%EFr(   c                    U H  nUR                  U5        M     U R                  R                  SU 5        SU l        U R                  R
                  R                  U5        UR                   H  nUR                  U   nUR                  U5       Vs/ s H  ofULd  M	  UPM     nnU(       d  MB  UR                  U5        US   R                  U   nUR                  5       R                  U5        UR                  5       R                  U5        UR                  5       R                  U5        UR                  5       R                  U5        M     UR                   R                  U5        gs  snf )z
Common helper for removal of standard Axes (via delaxes) and of child Axes.

Parameters
----------
ax : `~.AxesBase`
    The Axes to remove.
owners
    List of objects (list or _AxesStack) "owning" the Axes, from which the Axes
    will be remove()d.
_axes_change_eventTr   N)r<   _axobserversprocessr"   r   canvasrelease_mouse_axis_names_shared_axesget_siblings	_axis_mapget_major_formatterset_axisget_major_locatorget_minor_formatterget_minor_locator_twinned_axes)	r#   r   ro  ownerr   grouperothersiblingsremaining_axiss	            r&   rp  FigureBase._remove_axes  s6    ELL  	!!"6=
  ..r2NNDood+G+2+?+?+CW+C%TV+CHWNN2 &a[2248N..099.I,,.77G..099.I,,.77G # 	# Xs   E0 E0c                    SU l         U R                   H  nUR                  US9  M     / U l        [        U R                  5       H$  nUR                  5         U R                  U5        M&     / U l        / U l        / U l        / U l	        / U l
        / U l        U(       d  [        R                  " 5       U l        SU l        SU l        SU l        SU l        g)z
Clear the figure.

Parameters
----------
keep_observers : bool, default: False
    Set *keep_observers* to True if, for example,
    a gui widget is tracking the Axes in the figure.
Nkeep_observersT)ru   rt   clearrQ  r   rY  rn   ro   rp   rq   rr   rs   rj   CallbackRegistryru  rg   rh   ri   r"   )r#   r  subfigr   s       r&   r  FigureBase.clear  s     "& llFLLL7 #		"BHHJLL # 

 % 6 6 8D
r(   c                      U R                  US9$ )a5  
[*Discouraged*] Alias for the `clear()` method.

.. admonition:: Discouraged

    The use of ``clf()`` is discouraged. Use ``clear()`` instead.

Parameters
----------
keep_observers : bool, default: False
    Set *keep_observers* to True if, for example,
    a gui widget is tracking the Axes in the figure.
r  )r  )r#   r  s     r&   clfFigureBase.clf  s     zzz88r(   c                 6   [         R                  " U R                  /UQ70 UD6u  p4nUR                  SU R                  5        [         R
                  " XU40 UD6nU R                  R                  U5        U R                  R                  Ul	        SU l
        U$ )a  
Place a legend on the figure.

Call signatures::

    legend()
    legend(handles, labels)
    legend(handles=handles)
    legend(labels)

The call signatures correspond to the following different ways to use
this method:

**1. Automatic detection of elements to be shown in the legend**

The elements to be added to the legend are automatically determined,
when you do not pass in any extra arguments.

In this case, the labels are taken from the artist. You can specify
them either at artist creation or by calling the
:meth:`~.Artist.set_label` method on the artist::

    ax.plot([1, 2, 3], label='Inline label')
    fig.legend()

or::

    line, = ax.plot([1, 2, 3])
    line.set_label('Label via method')
    fig.legend()

Specific lines can be excluded from the automatic legend element
selection by defining a label starting with an underscore.
This is default for all artists, so calling `.Figure.legend` without
any arguments and without setting the labels manually will result in
no legend being drawn.


**2. Explicitly listing the artists and labels in the legend**

For full control of which artists have a legend entry, it is possible
to pass an iterable of legend artists followed by an iterable of
legend labels respectively::

    fig.legend([line1, line2, line3], ['label1', 'label2', 'label3'])


**3. Explicitly listing the artists in the legend**

This is similar to 2, but the labels are taken from the artists'
label properties. Example::

    line1, = ax1.plot([1, 2, 3], label='label1')
    line2, = ax2.plot([1, 2, 3], label='label2')
    fig.legend(handles=[line1, line2])


**4. Labeling existing plot elements**

.. admonition:: Discouraged

    This call signature is discouraged, because the relation between
    plot elements and labels is only implicit by their order and can
    easily be mixed up.

To make a legend for all artists on all Axes, call this function with
an iterable of strings, one for each legend item. For example::

    fig, (ax1, ax2) = plt.subplots(1, 2)
    ax1.plot([1, 3, 5], color='blue')
    ax2.plot([2, 4, 6], color='red')
    fig.legend(['the blues', 'the reds'])


Parameters
----------
handles : list of `.Artist`, optional
    A list of Artists (lines, patches) to be added to the legend.
    Use this together with *labels*, if you need full control on what
    is shown in the legend and the automatic mechanism described above
    is not sufficient.

    The length of handles and labels should be the same in this
    case. If they are not, they are truncated to the smaller length.

labels : list of str, optional
    A list of labels to show next to the artists.
    Use this together with *handles*, if you need full control on what
    is shown in the legend and the automatic mechanism described above
    is not sufficient.

Returns
-------
`~matplotlib.legend.Legend`

Other Parameters
----------------
%(_legend_kw_figure)s

See Also
--------
.Axes.legend

Notes
-----
Some artists are not supported by this function.  See
:ref:`legend_guide` for details.
bbox_transformT)mlegend_parse_legend_argsr   r   r4  Legendrs   r0  r<   r1  r"   )r#   rF  rw   handleslabelsls         r&   legendFigureBase.legend  s    ^ #*"<"<TYY"X"XQW"X*D,?,?@NN4&;F;A<<..
r(   c                    SU R                   0Ub  UO0 EUEn[        SXUS.UD6nUR                  U 5        [        Ul        U R
                  R                  U5        U R
                  R                  Ul        SU l	        U$ )a  
Add text to figure.

Parameters
----------
x, y : float
    The position to place the text. By default, this is in figure
    coordinates, floats in [0, 1]. The coordinate system can be changed
    using the *transform* keyword.

s : str
    The text string.

fontdict : dict, optional
    A dictionary to override the default text properties. If not given,
    the defaults are determined by :rc:`font.*`. Properties passed as
    *kwargs* override the corresponding ones given in *fontdict*.

Returns
-------
`~.text.Text`

Other Parameters
----------------
**kwargs : `~matplotlib.text.Text` properties
    Other miscellaneous text parameters.

    %(Text:kwdoc)s

See Also
--------
.Axes.text
.pyplot.text
	transform)rc   rd   r   Tr^   )
r4  r   r   r'   rZ  rq   r0  r<   r1  r"   )r#   rc   rd   sfontdictrw   effective_kwargsr   s           r&   r   FigureBase.textw  s    J ,,
#/xR
 

 9a19(894

$"jj//
r(   c           
      f   Uc  [        USS5      nUGcS  Uc  [        S5      e[        U[        R                  5      (       a  / UR
                  QO![        R                  " U5      (       a  / UQOU/S   R                  SS9nUR                  5       nUR                  5       b!  UR                  5       R                  (       d  SnU(       ab  [        U[        R                  R                  R                  5      (       a/  UR                  5       (       a  [         R"                  " U40 UD6u  p%O[         R$                  " U40 UD6u  p%UR'                  U5        UR)                  SSSS9  [+        US	5      (       aY  UR                  S
S9=nbG  XR,                  La9  [.        R0                  " S[3        U5       S[3        U R,                  5       S35        / SQn	[         R4                  " X!40 UR7                  5        V
Vs0 s H  u  pX;  d  M  X_M     snn
D6nS
UR                  SS9l        U$ s  snn
f )a	  
Add a colorbar to a plot.

Parameters
----------
mappable
    The `matplotlib.cm.ScalarMappable` (i.e., `.AxesImage`,
    `.ContourSet`, etc.) described by this colorbar.  This argument is
    mandatory for the `.Figure.colorbar` method but optional for the
    `.pyplot.colorbar` function, which sets the default to the current
    image.

    Note that one can create a `.ScalarMappable` "on-the-fly" to
    generate colorbars not attached to a previously drawn artist, e.g.
    ::

        fig.colorbar(cm.ScalarMappable(norm=norm, cmap=cmap), ax=ax)

cax : `~matplotlib.axes.Axes`, optional
    Axes into which the colorbar will be drawn.  If `None`, then a new
    Axes is created and the space for it will be stolen from the Axes(s)
    specified in *ax*.

ax : `~matplotlib.axes.Axes` or iterable or `numpy.ndarray` of Axes, optional
    The one or more parent Axes from which space for a new colorbar Axes
    will be stolen. This parameter is only used if *cax* is not set.

    Defaults to the Axes that contains the mappable used to create the
    colorbar.

use_gridspec : bool, optional
    If *cax* is ``None``, a new *cax* is created as an instance of
    Axes.  If *ax* is positioned with a subplotspec and *use_gridspec*
    is ``True``, then *cax* is also positioned with a subplotspec.

Returns
-------
colorbar : `~matplotlib.colorbar.Colorbar`

Other Parameters
----------------
%(_make_axes_kw_doc)s
%(_colormap_kw_doc)s

Notes
-----
If *mappable* is a `~.contour.ContourSet`, its *extend* kwarg is
included automatically.

The *shrink* kwarg provides a simple way to scale the colorbar with
respect to the Axes. Note that if *cax* is specified, it determines the
size of the colorbar, and *shrink* and *aspect* are ignored.

For more precise control, you can manually specify the positions of the
axes objects in which the mappable and the colorbar are drawn.  In this
case, do not use any of the Axes properties kwargs.

It is known that some vector graphics viewers (svg and pdf) render
white gaps between segments of the colorbar.  This is due to bugs in
the viewers, not Matplotlib.  As a workaround, the colorbar can be
rendered with overlapping segments::

    cbar = colorbar()
    cbar.solids.set_edgecolor("face")
    draw()

However, this has negative consequences in other circumstances, e.g.
with semi-transparent images (alpha < 1) and colorbar extensions;
therefore, this workaround is not used by default (see issue #1188).

Nr   zUnable to determine Axes to steal space for Colorbar. Either provide the *cax* argument to use as the Axes for the Colorbar, provide the *ax* argument to steal space from it, or add *mappable* to an Axes.r   Fr   r   )visibler   axisr!   Tz&Adding colorbar to a different Figure z than z! which fig.colorbar is called on.)fractionpadshrinkaspectr	  panchor)r   r?   r@  rB  ndarrayflatiterabler!   gcar   colorbar_gridspecr   r   rO  rP  r   cbarmake_axes_gridspec	make_axesrX  gridr   r   r   warn_externalreprColorbaritemsr"   )r#   mappablecaxr   use_gridspecrw   r%   
current_axmappable_host_figNON_COLORBAR_KEYSkvcbs                r&   colorbarFigureBase.colorbar  s   V :640B;z => > )RZZ88
"''
 kk"ooUrUT1 )jej4  J%%'3--/AA$"2sxx~~'?'?@@**,,"55bCFCV"nnR:6:GGJHHU&vH>Hl++&.&9&9t&9&DD"Q (9(99""@ 1236 1 123 4567H]]3 L#\\^-K+TQq/IDAD^-K L+/E"(	-Ks   <H-H-c                    U R                  5       b6  U R                  5       R                  (       d  [        R                  " S5        gU R                  R                  XX4XV5        U R                   HD  nUR                  5       c  M  UR                  UR                  5       R                  U 5      5        MF     SU l
        g)a  
Adjust the subplot layout parameters.

Unset parameters are left unmodified; initial values are given by
:rc:`figure.subplot.[name]`.

.. plot:: _embedded_plots/figure_subplots_adjust.py

Parameters
----------
left : float, optional
    The position of the left edge of the subplots,
    as a fraction of the figure width.
right : float, optional
    The position of the right edge of the subplots,
    as a fraction of the figure width.
bottom : float, optional
    The position of the bottom edge of the subplots,
    as a fraction of the figure height.
top : float, optional
    The position of the top edge of the subplots,
    as a fraction of the figure height.
wspace : float, optional
    The width of the padding between subplots,
    as a fraction of the average Axes width.
hspace : float, optional
    The height of the padding between subplots,
    as a fraction of the average Axes height.
NzThis figure was using a layout engine that is incompatible with subplots_adjust and/or tight_layout; not calling subplots_adjust.T)r   r   r   r  subplotparsrS   r   r   _set_positionget_positionr"   )r#   r  r   rightr   wspacehspacer   s           r&   r   FigureBase.subplots_adjust!  s    > ""$0**,>>/0 e&I))B!!#/  !3!3!5!B!B4!HI  
r(   c                    Uc  U R                   n[        R                  " U5       Vs/ s H  o"R                  5       c  M  UPM     nnU GH  n[        R                  SUR                  5       5        UR                  5       R                  nUR                  R                  5       nU H  nUR                  R                  5       U:X  d  M#  UR                  5       R                  nUS:X  a  UR                  UR                  :X  d$  US:X  d  Me  UR                  UR                  :X  d  M  U R                  S   R                  X%5        M     GM     gs  snf )a  
Align the xlabels of subplots in the same subplot row if label
alignment is being done automatically (i.e. the label position is
not manually set).

Alignment persists for draw events after this is called.

If a label is on the bottom, it is aligned with labels on Axes that
also have their label on the bottom and that have the same
bottom-most subplot row.  If the label is on the top,
it is aligned with labels on Axes with the same top-most row.

Parameters
----------
axs : list of `~matplotlib.axes.Axes`
    Optional list of (or `~numpy.ndarray`) `~matplotlib.axes.Axes`
    to align the xlabels.
    Default is to align all Axes on the figure.

See Also
--------
matplotlib.figure.Figure.align_ylabels
matplotlib.figure.Figure.align_titles
matplotlib.figure.Figure.align_labels

Notes
-----
This assumes that all Axes in ``axs`` are from the same `.GridSpec`,
so that their `.SubplotSpec` positions correspond to figure positions.

Examples
--------
Example with rotated xtick labels::

    fig, axs = plt.subplots(1, 2)
    for tick in axs[0].get_xticklabels():
        tick.set_rotation(55)
    axs[0].set_xlabel('XLabel 0')
    axs[1].set_xlabel('XLabel 1')
    fig.align_xlabels()
N Working on: %sr   r   rc   )r   rB  ravelr   _logdebug
get_xlabelrowspanxaxisget_label_positionstartstoprl   join)r#   rl  r   r  posaxcrowspancs          r&   align_xlabelsFigureBase.align_xlabelsM  s    T ;))CHHSMNMb-?-?-ArMNBJJ("--/:((*22G((--/C 99//1S8"224<<Hu(..)H8O0M005::2C   O   E Ec                    Uc  U R                   n[        R                  " U5       Vs/ s H  o"R                  5       c  M  UPM     nnU GH  n[        R                  SUR                  5       5        UR                  5       R                  nUR                  R                  5       nU H  nUR                  R                  5       U:X  d  M#  UR                  5       R                  nUS:X  a  UR                  UR                  :X  d$  US:X  d  Me  UR                  UR                  :X  d  M  U R                  S   R                  X%5        M     GM     gs  snf )a  
Align the ylabels of subplots in the same subplot column if label
alignment is being done automatically (i.e. the label position is
not manually set).

Alignment persists for draw events after this is called.

If a label is on the left, it is aligned with labels on Axes that
also have their label on the left and that have the same
left-most subplot column.  If the label is on the right,
it is aligned with labels on Axes with the same right-most column.

Parameters
----------
axs : list of `~matplotlib.axes.Axes`
    Optional list (or `~numpy.ndarray`) of `~matplotlib.axes.Axes`
    to align the ylabels.
    Default is to align all Axes on the figure.

See Also
--------
matplotlib.figure.Figure.align_xlabels
matplotlib.figure.Figure.align_titles
matplotlib.figure.Figure.align_labels

Notes
-----
This assumes that all Axes in ``axs`` are from the same `.GridSpec`,
so that their `.SubplotSpec` positions correspond to figure positions.

Examples
--------
Example with large yticks labels::

    fig, axs = plt.subplots(2, 1)
    axs[0].plot(np.arange(0, 1000, 50))
    axs[0].set_ylabel('YLabel 0')
    axs[1].set_ylabel('YLabel 1')
    fig.align_ylabels()
Nr  r  r  rd   )r   rB  r  r   r  r  
get_ylabelcolspanyaxisr  r  r  rl   r  )r#   rl  r   r  r  r  colspancs          r&   align_ylabelsFigureBase.align_ylabels  s    R ;))CHHSMNMb-?-?-ArMNBJJ("--/:((*22G((--/C 99//1S8"224<<Hv'--8>>*I7Nw||x}}/L005::2C   Or  c                    Uc  U R                   n[        R                  " U5       Vs/ s H  o"R                  5       c  M  UPM     nnU H  n[        R                  SUR                  5       5        UR                  5       R                  nU HW  nUR                  5       R                  nUR                  UR                  :X  d  M9  U R                  S   R                  X$5        MY     M     gs  snf )ap  
Align the titles of subplots in the same subplot row if title
alignment is being done automatically (i.e. the title position is
not manually set).

Alignment persists for draw events after this is called.

Parameters
----------
axs : list of `~matplotlib.axes.Axes`
    Optional list of (or ndarray) `~matplotlib.axes.Axes`
    to align the titles.
    Default is to align all Axes on the figure.

See Also
--------
matplotlib.figure.Figure.align_xlabels
matplotlib.figure.Figure.align_ylabels
matplotlib.figure.Figure.align_labels

Notes
-----
This assumes that all Axes in ``axs`` are from the same `.GridSpec`,
so that their `.SubplotSpec` positions correspond to figure positions.

Examples
--------
Example with titles::

    fig, axs = plt.subplots(1, 2)
    axs[0].set_aspect('equal')
    axs[0].set_title('Title 0')
    axs[1].set_title('Title 1')
    fig.align_titles()
Nr  re   )r   rB  r  r   r  r  	get_titler  r  rl   r  )r#   rl  r   r  r  r  s         r&   align_titlesFigureBase.align_titles  s    H ;))CHHSMNMb-?-?-ArMNBJJ(",,.9((*22G..088MMX^^3,,W5::2C   Os   C- C-c                 @    U R                  US9  U R                  US9  g)a  
Align the xlabels and ylabels of subplots with the same subplots
row or column (respectively) if label alignment is being
done automatically (i.e. the label position is not manually set).

Alignment persists for draw events after this is called.

Parameters
----------
axs : list of `~matplotlib.axes.Axes`
    Optional list (or `~numpy.ndarray`) of `~matplotlib.axes.Axes`
    to align the labels.
    Default is to align all Axes on the figure.

See Also
--------
matplotlib.figure.Figure.align_xlabels
matplotlib.figure.Figure.align_ylabels
matplotlib.figure.Figure.align_titles

Notes
-----
This assumes that all Axes in ``axs`` are from the same `.GridSpec`,
so that their `.SubplotSpec` positions correspond to figure positions.
)rl  N)r  r  )r#   rl  s     r&   align_labelsFigureBase.align_labels  s&    4 	s#s#r(   c                 F    UR                  SS5      n[        SXU S.UD6nU$ )a[  
Low-level API for creating a `.GridSpec` that has this figure as a parent.

This is a low-level API, allowing you to create a gridspec and
subsequently add subplots based on the gridspec. Most users do
not need that freedom and should use the higher-level methods
`~.Figure.subplots` or `~.Figure.subplot_mosaic`.

Parameters
----------
nrows : int, default: 1
    Number of rows in grid.

ncols : int, default: 1
    Number of columns in grid.

Returns
-------
`.GridSpec`

Other Parameters
----------------
**kwargs
    Keyword arguments are passed to `.GridSpec`.

See Also
--------
matplotlib.pyplot.subplots

Examples
--------
Adding a subplot that spans two rows::

    fig = plt.figure()
    gs = fig.add_gridspec(2, 2)
    ax1 = fig.add_subplot(gs[0, 0])
    ax2 = fig.add_subplot(gs[1, 0])
    # spans two rows:
    ax3 = fig.add_subplot(gs[:, 1])

rK  N)ri  rj  rK  r^   )r9   r   )r#   ri  rj  rw   _rk  s         r&   rg  FigureBase.add_gridspec  s.    V JJx&FEtFvF	r(   c                 N   [        XU XEUUSSSSS9n	[        R                  " X4[        S9n
[	        U5       H0  n[	        U5       H  nU R
                  " XU4   40 UD6XU4'   M      M2     U R                  5       cr  Uc  Ubl  U	R                  U 5      u  pnn[        XU5       HG  u  nnn[        UUU5       H/  u  nnn[        R                  " UUUU5      nUR                  US9  M1     MI     U(       a0  U
R                  S:X  a  U
R                  5       $ U
R                  5       $ U
$ )aJ  
Add a set of subfigures to this figure or subfigure.

A subfigure has the same artist methods as a figure, and is logically
the same as a figure, but cannot print itself.
See :doc:`/gallery/subplots_axes_and_figures/subfigures`.

.. versionchanged:: 3.10
    subfigures are now added in row-major order.

Parameters
----------
nrows, ncols : int, default: 1
    Number of rows/columns of the subfigure grid.

squeeze : bool, default: True
    If True, extra dimensions are squeezed out from the returned
    array of subfigures.

wspace, hspace : float, default: None
    The amount of width/height reserved for space between subfigures,
    expressed as a fraction of the average subfigure width/height.
    If not given, the values will be inferred from rcParams if using
    constrained layout (see `~.ConstrainedLayoutEngine`), or zero if
    not using a layout engine.

width_ratios : array-like of length *ncols*, optional
    Defines the relative widths of the columns. Each column gets a
    relative width of ``width_ratios[i] / sum(width_ratios)``.
    If not given, all columns will have the same width.

height_ratios : array-like of length *nrows*, optional
    Defines the relative heights of the rows. Each row gets a
    relative height of ``height_ratios[i] / sum(height_ratios)``.
    If not given, all rows will have the same height.
r   r   )ri  rj  rK  r  r  r_  r`  r  r  r   r   dtyper   )r   rB  emptyobjectrangeadd_subfigurer   get_grid_positionszipr   from_extents_redo_transform_rel_figr   itemr^  )r#   ri  rj  r^  r  r  r_  r`  rw   rk  sfarrijbottomstopsleftsrightssfrowr   r   sfr  r  r   s                           r&   
subfiguresFigureBase.subfiguresC  s4   P Et##/$1AaQ	8 %v6uA5\"00qDDVDd "  !!#+1C171C ,.+@+@+F(G5&&)%$&?"vs'*5%'@OBe,,T65#FD..D.9 (A '@
  $)::?5::<GG Lr(   c                     [        X40 UD6nU =R                  U/-  sl        U R                  R                  Ul        [        Ul        SU l        U$ )ap  
Add a `.SubFigure` to the figure as part of a subplot arrangement.

Parameters
----------
subplotspec : `.gridspec.SubplotSpec`
    Defines the region in a parent gridspec where the subfigure will
    be placed.

Returns
-------
`.SubFigure`

Other Parameters
----------------
**kwargs
    Are passed to the `.SubFigure` object.

See Also
--------
.Figure.subfigures
T)	SubFigurert   r<   r1  r'   rZ  r"   )r#   subplotspecrw   r  s       r&   r  FigureBase.add_subfigure  sI    . t3F3 LL//2
	r(   c                 t    U R                   R                  U5        U R                  R                  SU 5        U$ )z.Set the current Axes to be *a* and return *a*.rt  )rW  rA   ru  rv  r:   s     r&   rX  FigureBase.sca  s0    Q!!"6=r(   c                 `    U R                   R                  5       nUb  U$ U R                  5       $ )aT  
Get the current Axes.

If there is currently no Axes on this Figure, a new one is created
using `.Figure.add_subplot`.  (To test whether there is currently an
Axes on a Figure, check whether ``figure.axes`` is empty.  To test
whether there is currently a Figure on the pyplot figure stack, check
whether `.pyplot.get_fignums()` is empty.)
)rW  rK   rL  rq  s     r&   r  FigureBase.gca  s.     ]]""$^r;)9)9);;r(   c                     U R                   R                  5       nUc  gUR                  5       nUb  U$ [        U R                  5       H  nUR                  5       nUc  M  Us  $    g)a  
Get the current colorable artist.

Specifically, returns the current `.ScalarMappable` instance (`.Image`
created by `imshow` or `figimage`, `.Collection` created by `pcolor` or
`scatter`, etc.), or *None* if no such instance has been defined.

The current image is an attribute of the current Axes, or the nearest
earlier Axes in the current figure that contains an image.

Notes
-----
Historically, the only colorable artists were images; hence the name
``gci`` (get current image).
N)rW  rK   _gcireversedr   )r#   r   ims      r&   r  FigureBase._gci  sb    $ ]]""$:WWY>I 499%BB~	 & r(   )
axes_classpolar
projectionc                v   Ub  U(       d  Ub  [        S5      eUnXT4$ U(       a  Ub  US:w  a  [        SU SU< S35      eSn[        U[        5      (       d  Uc  [        R                  " U5      nXT4$ [        US5      (       a'  UR                  5       u  pVUR                  " S0 UD6  XT4$ [        SU< 35      e)	z
Handle the args/kwargs to add_axes/add_subplot/gca, returning::

    (axes_proj_class, proj_class_kwargs)

which can be used for new Axes initialization/identification.
z7Cannot combine 'axes_class' and 'projection' or 'polar'r  zpolar=z, yet projection=z1. Only one of these arguments should be supplied._as_mpl_axeszJprojection must be a string, None or implement a _as_mpl_axes method, not r^   )	r?   r@  rT  r   get_projection_classr   r  rS   r>  )r#   r  r  r  rw   rG  extra_kwargss          r&   rD  +FigureBase._process_projection_requirements  s     !
. MO O)(  ''# )jG.C$ '8 GJ J  %
*c**j.@#.#C#CJ#O   '' ^441;1H1H1J. --
  ''  00:~?@ @r(   c                 >   U R                  5        Vs/ s H3  nUR                  5       (       d  M  UR                  5       (       d  M1  UPM5     nnU R                   H9  nUR                  5       (       d  M  UR	                  UR                  5       5        M;     U$ s  snf )zE
Return a list of Artists typically used in `.Figure.get_tightbbox`.
)r   r  get_in_layoutr   extendget_default_bbox_extra_artists)r#   r~   bbox_artistsr   s       r&   r  )FigureBase.get_default_bbox_extra_artists  s     .2->->-@ N-@6"..0 5;5I5I5K -@ N))B~~##B$E$E$GH  Ns   BBBbbox_extra_artistsc                \   Uc  U R                  SS9R                  5       n/ nUc`  U R                  5        Vs/ s HD  nX@R                  ;  d  M  UR	                  5       (       d  M+  UR                  5       (       d  MB  UPMF     nnOUnU H*  nUR                  U5      nUc  M  UR                  U5        M,     U R                   H;  nUR	                  5       (       d  M   UR                  XS9nUR                  U5        M=     U V	s/ s Hu  n	[        R                  " U	R                  5      (       d  M*  [        R                  " U	R                  5      (       d  MQ  U	R                  S:w  d  U	R                  S:w  d  Ms  U	PMw     nn	[        U S5      n
[        U5      S:X  a   U
(       a  U R                  $ U R                   /n["        R$                  " U5      nU
(       a#  ['        XR(                  R+                  5       5      nU$ s  snf ! [         a    UR                  U5      n GN7f = fs  sn	f )a  
Return a (tight) bounding box of the figure *in inches*.

Note that `.FigureBase` differs from all other artists, which return
their `.Bbox` in pixels.

Artists that have ``artist.set_in_layout(False)`` are not included
in the bbox.

Parameters
----------
renderer : `.RendererBase` subclass
    Renderer that will be used to draw the figures (i.e.
    ``fig.canvas.get_renderer()``)

bbox_extra_artists : list of `.Artist` or ``None``
    List of artists to include in the tight bounding box.  If
    ``None`` (default), then all artist children of each Axes are
    included in the tight bounding box.

Returns
-------
`.BboxBase`
    containing the bounding box (in figure inches).
Tr   r   r   bbox_inches)r!   r   r   r   r  r  get_tightbboxr0  r>  rB  rC  widthheightr   r   r#  r   r   unionr   dpi_scale_transinverted)r#   r   r!  bbr~   rn   r;   r   r   r,  isfigure_bboxs               r&   r$  FigureBase.get_tightbbox  s   6 D1??AH%,0,=,=,? 8,?&!2 7=7I7I7K %335 ,?G 8G )GA??8,D		$ 
 ))B~~6++  , ID 		$   8A++agg& +-;;qxx+@ ww!|qxx1}  8 4/r7a<''' ii[

2#E+?+?+H+H+JKEO8$ ! 6++H5D68sA   HH&H=HH)H)4#H)H)=H)H&%H&c                     0 nU R                  5        HW  u  p#[        U[        5      (       a$  U H  nXA;   a  [        SU< S35      eX1U'   M     M>  X!;   a  [        SU< S35      eX1U'   MY     U$ )NzThe key z appears multiple times.)r  r@  rQ  r?   )per_subplot_kwexpandedr  r  sub_keys        r&   _norm_per_subplot_kwFigureBase._norm_per_subplot_kwQ  s    "((*DA!U## G*(8G;>V)WXX()W%  !
 =$xu4L%MNN + r(   c                    SU ;  a+  U R                  S5       Vs/ s H  n[        U5      PM     sn$ [        R                  " U 5      n U R	                  S5      R                  S5       Vs/ s H  n[        U5      PM     sn$ s  snf s  snf )N
;)splitlistinspectcleandocstrip)layoutlns     r&   _normalize_grid_string!FigureBase._normalize_grid_string`  sz    v'-||C'89'8DH'899 %%f-F'-||D'9'?'?'EF'EDH'EFF	 : Gs   B*B.)r\  r]  r_  r`  empty_sentinelra  r/  rb  c                  ^ ^^^^^^ T=(       d    0 m[        U	=(       d    0 5      n	T=(       d    0 mUb  SU	;   a  [        S5      eXYS'   Ub  SU	;   a  [        S5      eXIS'   [        U[        5      (       a@  T R	                  U5      nTR                  5        V
Vs0 s H  u  p[        U
5      U_M     snn
mT R                  T5      m[        R                  " [        X#S9  S mUU4S jmUUUU U4S jmT" U5      nUR                  u  pT R                  " X40 U	D6nT" X/T" U5      Q76 n[        [        UR                  5       5      5      nUR                  5        HS  nU(       a   UR!                  U5        UR#                  S	S
9  U(       d  M3  UR%                  U5        UR'                  S	S
9  MU     [)        T5      [)        U5      -
  =n(       a  [        SU S35      eU$ s  snn
f )as  
Build a layout of Axes based on ASCII art or nested lists.

This is a helper function to build complex GridSpec layouts visually.

See :ref:`mosaic`
for an example and full API documentation

Parameters
----------
mosaic : list of list of {hashable or nested} or str

    A visual layout of how you want your Axes to be arranged
    labeled as strings.  For example ::

       x = [['A panel', 'A panel', 'edge'],
            ['C panel', '.',       'edge']]

    produces 4 Axes:

    - 'A panel' which is 1 row high and spans the first two columns
    - 'edge' which is 2 rows high and is on the right edge
    - 'C panel' which in 1 row and 1 column wide in the bottom left
    - a blank space 1 row and 1 column wide in the bottom center

    Any of the entries in the layout can be a list of lists
    of the same form to create nested layouts.

    If input is a str, then it can either be a multi-line string of
    the form ::

      '''
      AAE
      C.E
      '''

    where each character is a column and each line is a row. Or it
    can be a single-line string where rows are separated by ``;``::

      'AB;CC'

    The string notation allows only single character Axes labels and
    does not support nesting but is very terse.

    The Axes identifiers may be `str` or a non-iterable hashable
    object (e.g. `tuple` s may not be used).

sharex, sharey : bool, default: False
    If True, the x-axis (*sharex*) or y-axis (*sharey*) will be shared
    among all subplots.  In that case, tick label visibility and axis
    units behave as for `subplots`.  If False, each subplot's x- or
    y-axis will be independent.

width_ratios : array-like of length *ncols*, optional
    Defines the relative widths of the columns. Each column gets a
    relative width of ``width_ratios[i] / sum(width_ratios)``.
    If not given, all columns will have the same width.  Equivalent
    to ``gridspec_kw={'width_ratios': [...]}``. In the case of nested
    layouts, this argument applies only to the outer layout.

height_ratios : array-like of length *nrows*, optional
    Defines the relative heights of the rows. Each row gets a
    relative height of ``height_ratios[i] / sum(height_ratios)``.
    If not given, all rows will have the same height. Equivalent
    to ``gridspec_kw={'height_ratios': [...]}``. In the case of nested
    layouts, this argument applies only to the outer layout.

subplot_kw : dict, optional
    Dictionary with keywords passed to the `.Figure.add_subplot` call
    used to create each subplot.  These values may be overridden by
    values in *per_subplot_kw*.

per_subplot_kw : dict, optional
    A dictionary mapping the Axes identifiers or tuples of identifiers
    to a dictionary of keyword arguments to be passed to the
    `.Figure.add_subplot` call used to create each subplot.  The values
    in these dictionaries have precedence over the values in
    *subplot_kw*.

    If *mosaic* is a string, and thus all keys are single characters,
    it is possible to use a single string instead of a tuple as keys;
    i.e. ``"AB"`` is equivalent to ``("A", "B")``.

    .. versionadded:: 3.7

gridspec_kw : dict, optional
    Dictionary with keywords passed to the `.GridSpec` constructor used
    to create the grid the subplots are placed on. In the case of
    nested layouts, this argument applies only to the outer layout.
    For more complex layouts, users should use `.Figure.subfigures`
    to create the nesting.

empty_sentinel : object, optional
    Entry in the layout to mean "leave this space empty".  Defaults
    to ``'.'``. Note, if *layout* is a string, it is processed via
    `inspect.cleandoc` to remove leading white space, which may
    interfere with using white-space as the empty sentinel.

Returns
-------
dict[label, Axes]
   A dictionary mapping the labels to the Axes objects.  The order of
   the Axes is left-to-right and top-to-bottom of their position in the
   total layout.

r`  rd  r_  re  )r\  r]  c                    U tp[        U[        5      (       a  [        S5      e[        USS9 Hl  u  p4[        U[        5      (       a  [        S5      e[	        U5      [	        U5      :w  d  M?  [        SU< S[	        U5       SU SU< S[	        U5       S35      e   [
        R                  " [	        U 5      [	        U5      4[        S	9n[        U 5       H  u  p4[        U5       H
  u  pgXuX64'   M     M      U$ )
z
Convert input into 2D array

We need to have this internal function rather than
``np.asarray(..., dtype=object)`` so that a list of lists
of lists does not get converted to an array of dimension > 2.

Returns
-------
2D object array
z$List mosaic specification must be 2Dr   )r  z@All of the rows must be the same length, however the first row (z) has length z	 and row z (r@  r  )r@  rT  r?   	enumerater   rB  zerosr  )inpr0restr  routr  r  s           r&   _make_array.FigureBase.subplot_mosaic.<locals>._make_array  s     IB"c"" !GHH!$a0a%%$%KLLr7c!f$$**,}SWI F##$#RuM#a&D 	 1 ((CHc"g.f=C!#%aLDA !I ) ' Jr(   c                    > [         R                  " 5       n0 n[        U 5       H[  u  p4[        U5       HG  u  pVUT:X  a  M  [         R                  " U5      (       d  T" U5      X#U4'   M6  UR	                  U5        MI     M]     [        U5      U4$ )z
Given a 2D object array, identify unique IDs and nested mosaics

Parameters
----------
mosaic : 2D object array

Returns
-------
unique_ids : tuple
    The unique non-sub mosaic entries in this mosaic
nested : dict[tuple[int, int], 2D object array]
)rj   _OrderedSetrD  is_scalar_or_stringrD   rQ  )	mosaic
unique_idsnestedr  rowr  r  rK  rA  s	          r&   _identify_keys_and_nested<FigureBase.subplot_mosaic.<locals>._identify_keys_and_nested  s     **,JF#F+%cNDAN* "66q99)4Q1v"q) + , $f,,r(   c           
        > [        5       n[        5       nU H  n[        R                  " X:H  5      n[        R                  " USS9u  p[        R                  " USS9S-   u  p[        X5      [        X5      4nX   U:g  R                  5       (       a  [        SU< SU< S35      eXlS4XXU	4'   M     UR                  5        H  u  u  pnSUS	4X]U4'   M     [        U5       H  nUU   u  nnnUS:X  aS  UnXd;   a  [        S
U SU< 35      eTR                  " X   40 S[        U5      0TETR                  U0 5      ED6nUXF'   Me  US	:X  a  UnUu  pUR                  u  nnT" XU4   R                  UU5      U/T" U5      Q76 n[        U5      [        U5      -  nU(       a  [        S
U SU< SU 35      eUR!                  U5        M  [#        S5      e   U$ )a  
Recursively do the mosaic.

Parameters
----------
gs : GridSpec
mosaic : 2D object array
    The input converted to a 2D array for this level.
unique_ids : tuple
    The identified scalar labels at this level of nesting.
nested : dict[tuple[int, int]], 2D object array
    The identified nested mosaics, if any.

Returns
-------
dict[label, Axes]
    A flat dict of all of the Axes created.
r   )r  r   zWhile trying to layout
z
we found that the label z4 specifies a non-rectangular or non-contiguous area.r   NrR  zThere are duplicate keys z in the layout
r   z between the outer layout
z
and the nested layout
zThis should never happen)rf  rB  argwhereminrI   sliceanyr?   r  r   rL  rT  getshapesubgridspecrv   rS   RuntimeError)rk  rP  rQ  rR  output
this_levelr   indx	start_row	start_colend_rowend_colslcr  r  nested_mosaicrG   argmethodr   rowscolsnested_outputoverlap
_do_layoutrT  r/  r#   ra  s                           r&   rn  -FigureBase.subplot_mosaic.<locals>._do_layout-  s^   & VF J #{{6>2')vvd';$	#%66$Q#7!#; Y0%	2KLK4',,..$26* =337( ;BBC C
 7;5H
y12 #$ *0%&*M8%D
q6" *8
 j)$.sO!c6 V#C~(+DTF K;;A**F G G))#SY$($ -00r:$B $&FLx'$'MDA!.!4!4JD$$.a4,,T48%% 3=A%M
 "&kC,>>G(7y A99?
 C66C_F 
 MM-0&'ABBM *N Mr(   T)skip_non_rectangular_axesz	The keys z/ are in *per_subplot_kw* but not in the mosaic.)rf  r?   r@  rT  r>  r  rQ  r2  r   check_isinstanceboolr\  rg  r@   iterrO   r\  _label_outer_xaxisr]  _label_outer_yaxisrv   )r#   rP  r\  r]  r_  r`  rA  ra  r/  rb  r  r  rj  rk  rk  retax0r   extrarn  rT  rK  s   `     ```          @@@r&   subplot_mosaicFigureBase.subplot_mosaicj  s   \  %2
;,"-'-2$+-  "I J J+8(#,  "I J J*6' fc""008F(6(<(<(>(>a!(>N 22>B 	d6A	<	-8]	 ]	~ V$\\
t9[9H&?&GH4

%&**,B		#%%%Ev		#%%%E  '#c(2252E7 #) )  
gs   G%c                 |    X:w  a  UR                  U 5        [        Ul        UR                  U R                  5        g r-   )r   r'   rZ  r3  r4  r:   s     r&   _set_artist_propsFigureBase._set_artist_props  s-    9LL1	++,r(   )rl   ru  rm   rg   rh   ri   rn   rr   rs   ro   rp   r"   rt   ru   rq   )g?   r  r   r-   F)r   r   )NNT)NNNNNN)r   r   TNNNN)FrX   rY   rZ   r[   r\   r3   r   r   r   r!   r   property	functoolspartialrK  r   r   r   r   Substitutioncopyr   r   r   r  r  r  r  r  r  r  r   r#  r)  r-  frameonr8  interpdr<  rL  rE  rh  rY  rp  r  r  r  r   r  r   r  r  r  r  rg  r  r  rX  r  r  rD  r  r$  staticmethodr2  r>  ry  r|  r]   __classcell__rx   s   @r&   r`   r`   v   s   B( >E+Z
%N$$ i''
>
:<FGR =X %'3__Z 2 !32?
 >h (W6__Z 2 !62?
 >f (W6__Z 2 !62?
**(,*(( {K0G!F n/ n/` }0 }0~H5D dHTG"$H!H9, u un / /b <@u un GK,0*X<D|;Dz-D^$:-^ 48'+48CJ<<B >B48!(F	G GR   G G 05U$(&)"&tsj	- -r(   r`   c                      ^  \ rS rSrSrSSSSS.U 4S jjr\S 5       r\S 5       r\R                  S	 5       rS
 r
S rS rSS jrS rSS jrS r\S 5       r\R$                  rS rSrU =r$ )r  i  a  
Logical figure that can be placed inside a figure.

See :ref:`figure-api-subfigure` for an index of methods on this class.
Typically instantiated using `.Figure.add_subfigure` or
`.SubFigure.add_subfigure`, or `.SubFigure.subfigures`.  A subfigure has
the same methods as a figure except for those particularly tied to the size
or dpi of the figure, and is confined to a prescribed region of the figure.
For example the following puts two subfigures side-by-side::

    fig = plt.figure()
    sfigs = fig.subfigures(1, 2)
    axsL = sfigs[0].subplots(1, 2)
    axsR = sfigs[1].subplots(2, 1)

See :doc:`/gallery/subplots_axes_and_figures/subfigures`
N        )	facecolor	edgecolorr  r  c                2  > [         TU ]  " S	0 UD6  Uc  SnUc  [        R                  S   nUc  [        R                  S   nX l        Xl        UR                  U l        UR                  U l        UR                  U l        UR                  U l	        UR                  U l
        UR                  U l        [        R                  " 5       U l        U R                  5         U R
                  R                   U l        [#        U R                  U R
                  R$                  5      U l        [)        U R&                  5      U l        [+        SSSUX4USU R$                  S9	U l        U R/                  U R,                  5        U R,                  R1                  S5        g)
a  
Parameters
----------
parent : `.Figure` or `.SubFigure`
    Figure or subfigure that contains the SubFigure.  SubFigures
    can be nested.

subplotspec : `.gridspec.SubplotSpec`
    Defines the region in a parent gridspec where the subfigure will
    be placed.

facecolor : default: ``"none"``
    The figure patch face color; transparent by default.

edgecolor : default: :rc:`figure.edgecolor`
    The figure patch edge color.

linewidth : float
    The linewidth of the frame (i.e. the edge linewidth of the figure
    patch).

frameon : bool, default: :rc:`figure.frameon`
    If ``False``, suppress drawing the figure background patch.

Other Parameters
----------------
**kwargs : `.SubFigure` properties, optional

    %(SubFigure:kwdoc)s
Nnonefigure.edgecolorfigure.frameonr   r   r   F)	xyr%  r&  r  r  r  r  	in_layoutr  r^   )rf   r3   r   r   _subplotspecr   r   rW  r  r(  ru  transFigurer   nullbbox_relativer  figbboxr   r4  r   r   r   r   r|  set_antialiased)	r#   parentr  r  r  r  r  rw   rx   s	           r&   r3   SubFigure.__init__  sQ   H 	"6"I%78I?ll#34G'"// !--%55"//!--!YY[$$&||++#D$6$6$(LL$?$?A	-dii8Qq'	t':':	<

 	tzz*

""5)r(   c                 .    U R                   R                  $ r-   )r   rw  r2   s    r&   rw  SubFigure.canvas  s    ||"""r(   c                 .    U R                   R                  $ r-   r   dpir2   s    r&   r  SubFigure.dpi	  s    ||r(   c                 $    XR                   l        g r-   r  )r#   values     r&   r  r  	  s     r(   c                 .    U R                   R                  $ )zI
Return the resolution of the parent figure in dots-per-inch as a float.
r  r2   s    r&   get_dpiSubFigure.get_dpi	  s     ||r(   c                 2    XR                   l        SU l        g)zZ
Set the resolution of parent figure in dots-per-inch.

Parameters
----------
val : float
TN)r   r  r"   r#   r$   s     r&   set_dpiSubFigure.set_dpi	  s     
r(   c                 6    U R                   R                  5       $ r-   )r   r   r2   s    r&   r   SubFigure._get_renderer	  s    ||))++r(   c                 x   Ub7  UR                   U R                  l         UR                  U R                  l        gU R                  R	                  5       n[
        R                  " UR                  5       5      n[
        R                  " UR                  5       5      nX0R                  R                     R                  5       UR                  5       -  nX@R                  R                     R                  5       UR                  5       -  nUSU R                  R                  R                   R                  5       UR                  5       -  nSUSU R                  R                  R                   R                  5       UR                  5       -  -
  nXx4U R                  l         Xu-   X-   4U R                  l        g)z
Make the transSubfigure bbox relative to Figure transform.

Parameters
----------
bbox : bbox or None
    If not None, then the bbox is used for relative bounding box.
    Otherwise, it is calculated from the subplotspec.
Nr   )p0r  p1r  get_gridspecrB  asarrayget_width_ratiosget_height_ratiosr  sumr  r  r  )	r#   r   rk  wrhrdxdyr   r   s	            r&   r  !SubFigure._redo_transform_rel_fig	  sU    $(GGD!$(GGD!++-ZZ++-.ZZ,,./!!))*..02668;!!))*..02668;0""**001557"&&(B3T&&..33488:RVVXEE!#!#"' 2r(   c                 6    U R                   R                  5       $ zW
Return whether constrained layout is being used.

See :ref:`constrainedlayout_guide`.
)r   get_constrained_layoutr2   s    r&   r   SubFigure.get_constrained_layout8	  s     ||2244r(   c                 4    U R                   R                  US9$ )a  
Get padding for ``constrained_layout``.

Returns a list of ``w_pad, h_pad`` in inches and
``wspace`` and ``hspace`` as fractions of the subplot.

See :ref:`constrainedlayout_guide`.

Parameters
----------
relative : bool
    If `True`, then convert from inches to figure relative.
)relative)r   get_constrained_layout_pads)r#   r  s     r&   r  %SubFigure.get_constrained_layout_pads@	  s     ||777JJr(   c                 6    U R                   R                  5       $ r-   )r   r   r2   s    r&   r   SubFigure.get_layout_engineP	  s    ||--//r(   c                      U R                   SS $ )aV  
List of Axes in the SubFigure.  You can access and modify the Axes
in the SubFigure through this list.

Modifying this list has no effect. Instead, use `~.SubFigure.add_axes`,
`~.SubFigure.add_subplot` or `~.SubFigure.delaxes` to add or remove an
Axes.

Note: The `.SubFigure.axes` property and `~.SubFigure.get_axes` method
are equivalent.
N)rm   r2   s    r&   r   SubFigure.axesS	  s     q!!r(   c           	      j   U R                  5       (       d  g U R                  U5      n UR                  SU R                  5       S9  U R                  R                  U5        [        R                  " XX R                  SS9R                  5        UR                  S5        SU l        g ! SU l        f = f)N	subfiguregidTr   F)r  r   
open_groupget_gidr   drawmimage_draw_list_compositing_imagesr!   ru   close_groupr"   r#   r   rn   s      r&   r  SubFigure.drawd	  s     !!((2	@JJOOH%00d)C)U)UW  - DJDJs   A8B) )	B2)ru  rW  r   r   r  r   r  r(  r  r   r"   r  r  r4  r-   r  )rX   rY   rZ   r[   r\   r3   r  rw  r  setterr  r  r   r  r  r  r   r   fgetget_axesr  r]   r  r  s   @r&   r  r    s    &  	C* C*J # #     	ZZ! ! 	,325K 0 " " yyH r(   r  c            
       >  ^  \ rS rSrSr\R                  " 5       rS rS r	  S@SSSSSSSSS.U 4S jjjr
U 4S	 jrS
 rSAS jrS rS rSBS jr\S 5       r\R&                  r\S 5       r\R,                  S 5       rS rS rSBS jr\" \\SS9rS r\R:                  " SSSS9S 5       rS r\R:                  " SSSS9S 5       r \R:                  " SS SS9S! 5       r!\R:                  " SS"SS9SCS# j5       r"S$ r#\$RJ                    SDSS%.S& jj5       r&SES' jr'S( r(S) r)S* r*S+ r+S, r,SBS- jr-SBS. jr.SCU 4S/ jjr/\0\1S0 5       5       r2S1 r3S2 r4U 4S3 jr5S4 r6S5 r7SS6.S7 jr8S8S9S\9Rt                  \9Rv                  \9Rx                  4S: jr=SFS; jr>S<SSSS=.S> jr?S?r@U =rA$ )GFigureix	  a  
The top level container for all the plot elements.

See `matplotlib.figure` for an index of class methods.

Attributes
----------
patch
    The `.Rectangle` instance representing the figure background patch.

suppressComposite
    For multiple images, the figure will make composite images
    depending on the renderer option_image_nocomposite function.  If
    *suppressComposite* is a boolean, this will override the renderer.
c                 F    S[        U R                  R                  5      -  $ )NzFigure(%gx%g))rQ  r   r   r2   s    r&   __str__Figure.__str__	  s    tyy~~!666r(   c                     SR                  U R                  R                  U R                  R                  S   U R                  R                  S   [        U R                  5      S9$ )Nz.<{clsname} size {h:g}x{w:g} with {naxes} Axes>r   r   )clsnamehwnaxes)formatrx   rX   r   r   r   r   r2   s    r&   __repr__Figure.__repr__	  sR    ?FFNN++iinnQ499>>!#4dii. G 
 	
r(   Nr  )r  r  r  r  r  tight_layoutconstrained_layoutr<  c                x  > [         TU ]  " S0 UD6  X l        SU l        U
bB  Ub  [        R
                  " S5        U	b  [        R
                  " S5        U R                  U
S9  OUb^  U	b  [        R
                  " S5        U R                  SS9  [        U[        5      (       a   U R                  5       R                  " S0 UD6  OnU	b\  [        U	[        5      (       a0  U R                  SS9  U R                  5       R                  " S0 U	D6  O&U	(       a  U R                  SS9  OU R                  U
S9  [        R                  " [        R                  S9U l        U R                  R                   nU" S	["        R$                  5      U" S
["        R$                  5      U" S
["        R$                  5      U" S["        R&                  5      U" S["        R&                  5      U" S["        R&                  5      U" S["        R&                  5      /U l        U" SU R*                  5      U l        U" SU R*                  5      U l        Uc  [0        R2                  S   nUc  [0        R2                  S   nUc  [0        R2                  S   nUc  [0        R2                  S   nUc  [0        R2                  S   n[4        R6                  " U5      R9                  5       (       a,  [4        R:                  " U5      S:  R=                  5       (       a  [?        SU 35      e[@        RB                  " SS/UQ76 U l"        [G        5       RI                  U5      U l%        X l&        [O        U RD                  U RJ                  5      U l(        U RP                  U l)        [U        U RP                  5      U l+        U RV                  U l,        [[        SSSUX4USS9U l.        U R_                  U R\                  5        U R\                  Ra                  S5        [        U 5        Uc
  [c        5       nXpl2        [g        5       U l4        U Rk                  5         g)a0  
Parameters
----------
figsize : 2-tuple of floats, default: :rc:`figure.figsize`
    Figure dimension ``(width, height)`` in inches.

dpi : float, default: :rc:`figure.dpi`
    Dots per inch.

facecolor : default: :rc:`figure.facecolor`
    The figure patch facecolor.

edgecolor : default: :rc:`figure.edgecolor`
    The figure patch edge color.

linewidth : float
    The linewidth of the frame (i.e. the edge linewidth of the figure
    patch).

frameon : bool, default: :rc:`figure.frameon`
    If ``False``, suppress drawing the figure background patch.

subplotpars : `~matplotlib.gridspec.SubplotParams`
    Subplot parameters. If not given, the default subplot
    parameters :rc:`figure.subplot.*` are used.

tight_layout : bool or dict, default: :rc:`figure.autolayout`
    Whether to use the tight layout mechanism. See `.set_tight_layout`.

    .. admonition:: Discouraged

        The use of this parameter is discouraged. Please use
        ``layout='tight'`` instead for the common case of
        ``tight_layout=True`` and use `.set_tight_layout` otherwise.

constrained_layout : bool, default: :rc:`figure.constrained_layout.use`
    This is equal to ``layout='constrained'``.

    .. admonition:: Discouraged

        The use of this parameter is discouraged. Please use
        ``layout='constrained'`` instead.

layout : {'constrained', 'compressed', 'tight', 'none', `.LayoutEngine`, None}, default: None
    The layout mechanism for positioning of plot elements to avoid
    overlapping Axes decorations (labels, ticks, etc). Note that
    layout managers can have significant performance penalties.

    - 'constrained': The constrained layout solver adjusts Axes sizes
      to avoid overlapping Axes decorations.  Can handle complex plot
      layouts and colorbars, and is thus recommended.

      See :ref:`constrainedlayout_guide` for examples.

    - 'compressed': uses the same algorithm as 'constrained', but
      removes extra space between fixed-aspect-ratio Axes.  Best for
      simple grids of Axes.

    - 'tight': Use the tight layout mechanism. This is a relatively
      simple algorithm that adjusts the subplot parameters so that
      decorations do not overlap.

      See :ref:`tight_layout_guide` for examples.

    - 'none': Do not use a layout engine.

    - A `.LayoutEngine` instance. Builtin layout classes are
      `.ConstrainedLayoutEngine` and `.TightLayoutEngine`, more easily
      accessible by 'constrained' and 'tight'.  Passing an instance
      allows third parties to provide their own layout engine.

    If not given, fall back to using the parameters *tight_layout* and
    *constrained_layout*, including their config defaults
    :rc:`figure.autolayout` and :rc:`figure.constrained_layout.use`.

Other Parameters
----------------
**kwargs : `.Figure` properties, optional

    %(Figure:kwdoc)s
NzdThe Figure parameters 'layout' and 'tight_layout' cannot be used together. Please use 'layout' only.zjThe Figure parameters 'layout' and 'constrained_layout' cannot be used together. Please use 'layout' only.)r<  ztThe Figure parameters 'tight_layout' and 'constrained_layout' cannot be used together. Please use 'layout' parametertightconstrained)signalskey_press_eventkey_release_eventbutton_press_eventbutton_release_eventscroll_eventmotion_notify_eventfigure.figsizez
figure.dpizfigure.facecolorr  r  r   (figure size must be positive finite not r  r   F)r  r%  r&  r  r  r  r  r  r^   )6rf   r3   r   _layout_enginer   r  set_layout_enginer@  rf  r   rv   rj   r  r   events_canvas_callbacks_connect_picklabler   _key_handler_mouse_handler_mouse_key_idspick_button_pick_id_scroll_pick_idr   r   rB  rC  r   arrayrZ  r?   r   from_boundsr#  r   scaler(  _dpir   r   r  r   r  r4  r   r   r|  r  r   r  r*   rW  r  )r#   figsizer  r  r  r  r  r  r  r  r<  rw   connectrx   s                r&   r3   Figure.__init__	  s   @ 	"6" "(""BC #.""IJ ""&"1%!-"")* ""'"2,--&&(,,<|<+,d33&&m&<&&(,,B/AB#&&m&< ""&"1
 "'!7!7$++"-((;;%}'A'AB')C)CD')C)CD(-*F*FG*M,H,HINM$@$@A)=+G+GH
  '';TYYG&~tyyA?ll#34G;,,|,C%78I%78I?ll#34G{{7#''))bhhw.?!.C-H-H-J-JG 'y* + +++Aq;7;'z//4	#D$4$4d6J6JK	yy*4995"..Qq'		

 	tzz*

""5)'/K&"

r(   c                 x   > U R                   R                  R                  5       (       d  [        TU ]  U5        g g r-   )rw  
widgetlocklockedrf   r  )r#   r   rx   s     r&   r  Figure.pick^
  s-    {{%%,,..GL$ /r(   c                     Ub  Uc  gUR                   UR                   :X  a  gU R                   H  n[        US5      (       d  M    g   g)z
Helper for set_layout engine

If the figure has used the old engine and added a colorbar then the
value of colorbar_gridspec must be the same on the new engine.
T	_colorbarF)r  r   r   )r#   oldnewr   s       r&   _check_layout_engines_compat#Figure._check_layout_engines_compatb
  sL     ;#+  C$9$99 ))Br;''  r(   c                 >   Uc>  [         R                  S   (       a  SnO#[         R                  S   (       a  SnOSU l        gUS:X  a  [        S0 UD6nOUS:X  a  [	        S0 UD6nOUS:X  a  [	        SSS0UD6nOrUS	:X  aE  U R                  b5  [        U R                  R                  U R                  R                  5      nO*SnO'[        U[        5      (       a  UnO[        S
U< 35      eU R                  U R                  U5      (       a  X0l        g[        S5      e)a!  
Set the layout engine for this figure.

Parameters
----------
layout : {'constrained', 'compressed', 'tight', 'none', `.LayoutEngine`, None}

    - 'constrained' will use `~.ConstrainedLayoutEngine`
    - 'compressed' will also use `~.ConstrainedLayoutEngine`, but with
      a correction that attempts to make a good layout for fixed-aspect
      ratio Axes.
    - 'tight' uses `~.TightLayoutEngine`
    - 'none' removes layout engine.

    If a `.LayoutEngine` instance, that instance will be used.

    If `None`, the behavior is controlled by :rc:`figure.autolayout`
    (which if `True` behaves as if 'tight' was passed) and
    :rc:`figure.constrained_layout.use` (which if `True` behaves as if
    'constrained' was passed).  If both are `True`,
    :rc:`figure.autolayout` takes priority.

    Users and libraries can define their own layout engines and pass
    the instance directly as well.

**kwargs
    The keyword arguments are passed to the layout engine to set things
    like padding and margin sizes.  Only used if *layout* is a string.

Nfigure.autolayoutr  figure.constrained_layout.user  
compressedcompressTr  zInvalid value for 'layout': zzColorbar layout of new layout engine not compatible with old engine, and a colorbar has been created.  Engine not changed.r^   )r   r   r  r   r   r   r   r  r@  r   r?   r  r^  )r#   r<  rw   new_layout_engines       r&   r  Figure.set_layout_engineu
  s/   > >||/0 =>&&*#W 1 ;F ;}$ 7 A& A|# 7 !B !B:@!Bv"".$;''99''99%!
 %)!-- &;F:FGG,,T-@-@->@ @"3  H I Ir(   c                     U R                   $ r-   )r  r2   s    r&   r   Figure.get_layout_engine
  s    """r(   c                 x    S[        U R                  5      R                  ;   a  SSKJn  UR                  U 5      $ g )NWebAggr   )backend_webagg)typerw  rX   matplotlib.backendsr  ipython_inline_display)r#   r  s     r&   _repr_html_Figure._repr_html_
  s4     tDKK(111:!88>> 2r(   Tc                    U R                   R                  c  [        S5      e U R                   R                  R                  5         g! [         a5  nU(       a$  [
        R                  " [        U5      5         SnAg SnAgSnAff = f)a  
If using a GUI backend with pyplot, display the figure window.

If the figure was not created using `~.pyplot.figure`, it will lack
a `~.backend_bases.FigureManagerBase`, and this method will raise an
AttributeError.

.. warning::

    This does not manage an GUI event loop. Consequently, the figure
    may only be shown briefly or not shown at all if you or your
    environment are not managing an event loop.

    Use cases for `.Figure.show` include running this from a GUI
    application (where there is persistently an event loop running) or
    from a shell, like IPython, that install an input hook to allow the
    interactive shell to accept input while the figure is also being
    shown and interactive.  Some, but not all, GUI toolkits will
    register an input hook on import.  See :ref:`cp_integration` for
    more details.

    If you're in a shell without input hook integration or executing a
    python script, you should use `matplotlib.pyplot.show` with
    ``block=True`` instead, which takes care of starting and running
    the event loop for you.

Parameters
----------
warn : bool, default: True
    If ``True`` and we are not running headless (i.e. on Linux with an
    unset DISPLAY), issue warning when called on a non-GUI backend.

NzYFigure.show works only for figures managed by pyplot, normally created by pyplot.figure())rw  managerAttributeErrorshowr   r   r  rT  )r#   warnexcs      r&   r!  Figure.show
  so    D ;;& 67 7	-KK$$& 	-""3s8,, 	-s   $A	 	
B&BBc                 6    U R                   R                  5       $ )a;  
List of Axes in the Figure. You can access and modify the Axes in the
Figure through this list.

Do not modify the list itself. Instead, use `~Figure.add_axes`,
`~.Figure.add_subplot` or `~.Figure.delaxes` to add or remove an Axes.

Note: The `.Figure.axes` property and `~.Figure.get_axes` method are
equivalent.
)rW  r6   r2   s    r&   r   Figure.axes
  s     }}$$&&r(   c                 R    [        U S5      (       a  U R                  $ [        S5      e)z5The figure id, used to identify figures in `.pyplot`._numberze'Figure' object has no attribute 'number'. In the future thiswill change to returning 'None' instead.)r   r(  r   r2   s    r&   numberFigure.number  s-     4##<< ;< <r(   c                 :    [         R                  " SSS9  Xl        g )Nr   zcChanging 'Figure.number' is deprecated since %(since)s and will raise an error starting %(removal)sr   )r   r   r(  )r#   nums     r&   r)  r*    s     ?	@ r(   c                     [        U R                  S5      (       a  U R                  R                  5       $ [        U 5      $ )Nget_renderer)r   rw  r.  r   r2   s    r&   r   Figure._get_renderer   s1    4;;//;;++-- &&r(   c                     U R                   $ r-   )r  r2   s    r&   _get_dpiFigure._get_dpi&  s    yyr(   c                     XR                   :X  a  gXl         U R                  R                  5       R                  U5        U R	                  5       u  p4U R                  X4US9  g)z_
Parameters
----------
dpi : float

forward : bool
    Passed on to `~.Figure.set_size_inches`
Nforward)r  r(  r  r  get_size_inchesset_size_inches)r#   r  r5  r  r  s        r&   _set_dpiFigure._set_dpi)  sV     ))	""$**3/##%Q73r(   z The resolution in dots per inch.r   c                 >    [        U R                  5       [        5      $ )z=Return whether `.Figure.tight_layout` is called when drawing.)r@  r   r   r2   s    r&   get_tight_layoutFigure.get_tight_layout<  s    $0024EFFr(   z3.6r  )alternativependingc                     Uc  [         R                  S   n[        U5      (       a  SOSn[        U[        5      (       a  UO0 nU R
                  " U40 UD6  SU l        g)a  
Set whether and how `.Figure.tight_layout` is called when drawing.

Parameters
----------
tight : bool or dict with keys "pad", "w_pad", "h_pad", "rect" or None
    If a bool, sets whether to call `.Figure.tight_layout` upon drawing.
    If ``None``, use :rc:`figure.autolayout` instead.
    If a dict, pass it as kwargs to `.Figure.tight_layout`, overriding the
    default paddings.
Nr  r  r  Tr   r   rr  r@  rf  r  r"   )r#   r  _tight_tight_parameterss       r&   set_tight_layoutFigure.set_tight_layout@  sV     =LL!45E KKV%/t%<%<E"v;):;
r(   c                 >    [        U R                  5       [        5      $ r  )r@  r   r   r2   s    r&   r  Figure.get_constrained_layoutU  s     $0024KLLr(   z set_layout_engine('constrained')c                     Uc  [         R                  S   n[        U5      (       a  SOSn[        U[        5      (       a  UO0 nU R
                  " U40 UD6  SU l        g)a  
Set whether ``constrained_layout`` is used upon drawing.

If None, :rc:`figure.constrained_layout.use` value will be used.

When providing a dict containing the keys ``w_pad``, ``h_pad``
the default ``constrained_layout`` paddings will be
overridden.  These pads are in inches and default to 3.0/72.0.
``w_pad`` is the width padding and ``h_pad`` is the height padding.

Parameters
----------
constrained : bool or dict or None
Nr  r  r  Tr@  )r#   r  _constrained_parameterss       r&   set_constrained_layoutFigure.set_constrained_layout]  sW    " ,,'FGK(,[(9(9}v%/T%B%Bk|;{;
r(   z figure.get_layout_engine().set()c                     [        U R                  5       [        5      (       a!  U R                  5       R                  " S0 UD6  gg)a  
Set padding for ``constrained_layout``.

Tip: The parameters can be passed from a dictionary by using
``fig.set_constrained_layout(**pad_dict)``.

See :ref:`constrainedlayout_guide`.

Parameters
----------
w_pad : float, default: :rc:`figure.constrained_layout.w_pad`
    Width padding in inches.  This is the pad around Axes
    and is meant to make sure there is enough room for fonts to
    look good.  Defaults to 3 pts = 0.04167 inches

h_pad : float, default: :rc:`figure.constrained_layout.h_pad`
    Height padding in inches. Defaults to 3 pts.

wspace : float, default: :rc:`figure.constrained_layout.wspace`
    Width padding between subplots, expressed as a fraction of the
    subplot width.  The total padding ends up being w_pad + wspace.

hspace : float, default: :rc:`figure.constrained_layout.hspace`
    Height padding between subplots, expressed as a fraction of the
    subplot width. The total padding ends up being h_pad + hspace.

Nr^   )r@  r   r   rv   )r#   rw   s     r&   set_constrained_layout_pads"Figure.set_constrained_layout_padsu  s;    > d,,.0GHH""$((262 Ir(   zfig.get_layout_engine().get()c                 L   [        U R                  5       [        5      (       d  gU R                  5       R                  5       nUS   nUS   nUS   nUS   nU(       aD  Uc  Ub>  U R	                  5       nUR
                  nX8-  UR                  -  nXH-  UR                  -  nX4XV4$ )aU  
Get padding for ``constrained_layout``.

Returns a list of ``w_pad, h_pad`` in inches and
``wspace`` and ``hspace`` as fractions of the subplot.
All values are None if ``constrained_layout`` is not used.

See :ref:`constrainedlayout_guide`.

Parameters
----------
relative : bool
    If `True`, then convert from inches to figure relative.
)NNNNw_padh_padr  r  )r@  r   r   r[  r   r  r%  r&  )	r#   r  r   rP  rQ  r  r  r   r  s	            r&   r  "Figure.get_constrained_layout_pads  s    " $0024KLL)%%'++-WWhh*e.?))+H,,CK(..0EK(//1EV++r(   c                     Xl         g)zV
Set the canvas that contains the figure

Parameters
----------
canvas : FigureCanvas
N)rw  )r#   rw  s     r&   
set_canvasFigure.set_canvas  s	     r(   )	colorizerc          
         U
(       aP  U R                  5       nUR                  S   UR                  S   4 Vs/ s H  oU-  PM	     nnU R                  USS9  [        R                  " U 4XeUX#U	S.UD6n[
        Ul        UR                  U5        UR                  U5        Uc!  UR                  XUS9  UR                  Xx5        U R                  R                  U5        U R                  R                  Ul        SU l        U$ s  snf )a  
Add a non-resampled image to the figure.

The image is attached to the lower or upper left corner depending on
*origin*.

Parameters
----------
X
    The image data. This is an array of one of the following shapes:

    - (M, N): an image with scalar data.  Color-mapping is controlled
      by *cmap*, *norm*, *vmin*, and *vmax*.
    - (M, N, 3): an image with RGB values (0-1 float or 0-255 int).
    - (M, N, 4): an image with RGBA values (0-1 float or 0-255 int),
      i.e. including transparency.

xo, yo : int
    The *x*/*y* image offset in pixels.

alpha : None or float
    The alpha blending value.

%(cmap_doc)s

    This parameter is ignored if *X* is RGB(A).

%(norm_doc)s

    This parameter is ignored if *X* is RGB(A).

%(vmin_vmax_doc)s

    This parameter is ignored if *X* is RGB(A).

origin : {'upper', 'lower'}, default: :rc:`image.origin`
    Indicates where the [0, 0] index of the array is in the upper left
    or lower left corner of the Axes.

resize : bool
    If *True*, resize the figure to match the given image size.

%(colorizer_doc)s

    This parameter is ignored if *X* is RGB(A).

Returns
-------
`matplotlib.image.FigureImage`

Other Parameters
----------------
**kwargs
    Additional kwargs are `.Artist` kwargs passed on to `.FigureImage`.

Notes
-----
figimage complements the Axes image (`~matplotlib.axes.Axes.imshow`)
which will be resampled to fit the current Axes.  If you want
a resampled image to fill the entire figure, you can define an
`~matplotlib.axes.Axes` with extent [0, 0, 1, 1].

Examples
--------
::

    f = plt.figure()
    nx = int(f.get_figwidth() * f.dpi)
    ny = int(f.get_figheight() * f.dpi)
    data = np.random.random((ny, nx))
    f.figimage(data)
    plt.show()
r   r   Tr4  )cmapnormrV  offsetxoffsetyorigin)vminvmax)r  r\  r7  r  FigureImager'   rZ  	set_array	set_alpha_check_exclusionary_keywordsset_climrr   r0  r<   r1  r"   )r#   XxoyoalpharY  rX  r]  r^  r\  resizerV  rw   r  rc   r   r  s                    r&   figimageFigure.figimage  s    Z ,,.C)*QWWQZ(@A(@13w(@GA  $ 7 94*3(*'-9 289 3
Q
U<++It+LKK#2 KK..
	# Bs   Dc                    Uc  Uu  p[         R                  " X/5      n[         R                  " U5      R                  5       (       a  US:  R	                  5       (       a  [        SU 35      eX@R                  l        U(       aG  U R                  R                  nUb.  UR                  " X@R                  -  R                  [        5      6   SU l        g)a  
Set the figure size in inches.

Call signatures::

     fig.set_size_inches(w, h)  # OR
     fig.set_size_inches((w, h))

Parameters
----------
w : (float, float) or float
    Width and height in inches (if height not specified as a separate
    argument) or width.
h : float
    Height in inches.
forward : bool, default: True
    If ``True``, the canvas size is automatically updated, e.g.,
    you can resize the figure window from the shell.

See Also
--------
matplotlib.figure.Figure.get_size_inches
matplotlib.figure.Figure.set_figwidth
matplotlib.figure.Figure.set_figheight

Notes
-----
To transform from pixels to inches divide by `Figure.dpi`.
Nr   r  T)rB  r  rC  r   rZ  r?   r#  r  rw  r  rh  r  astyperS  r"   )r#   r  r  r5  r   r  s         r&   r7  Figure.set_size_inches$  s    < 9DAxx{{4 $$&&4!8..*:*:GvNOO"kk))G" 8 8 =>
r(   c                 V    [         R                  " U R                  R                  5      $ )a[  
Return the current size of the figure in inches.

Returns
-------
ndarray
   The size (width, height) of the figure in inches.

See Also
--------
matplotlib.figure.Figure.set_size_inches
matplotlib.figure.Figure.get_figwidth
matplotlib.figure.Figure.get_figheight

Notes
-----
The size in pixels can be obtained by multiplying with `Figure.dpi`.
)rB  r  r#  r  r2   s    r&   r6  Figure.get_size_inchesN  s    & xx((++,,r(   c                 .    U R                   R                  $ )z"Return the figure width in inches.)r#  r%  r2   s    r&   get_figwidthFigure.get_figwidthc  s    %%%r(   c                 .    U R                   R                  $ )z#Return the figure height in inches.)r#  r&  r2   s    r&   get_figheightFigure.get_figheightg  s    &&&r(   c                     U R                   $ )z2Return the resolution in dots per inch as a float.)r  r2   s    r&   r  Figure.get_dpik  s    xxr(   c                     Xl         SU l        g)zW
Set the resolution of the figure in dots-per-inch.

Parameters
----------
val : float
TN)r  r"   r  s     r&   r  Figure.set_dpio  s     
r(   c                 @    U R                  XR                  5       US9  g)z
Set the width of the figure in inches.

Parameters
----------
val : float
forward : bool
    See `set_size_inches`.

See Also
--------
matplotlib.figure.Figure.set_figheight
matplotlib.figure.Figure.set_size_inches
r4  N)r7  rt  r#   r$   r5  s      r&   set_figwidthFigure.set_figwidthz  s      	S"4"4"6Hr(   c                 @    U R                  U R                  5       XS9  g)z
Set the height of the figure in inches.

Parameters
----------
val : float
forward : bool
    See `set_size_inches`.

See Also
--------
matplotlib.figure.Figure.set_figwidth
matplotlib.figure.Figure.set_size_inches
r4  N)r7  rq  r{  s      r&   set_figheightFigure.set_figheight  s      	T..0#Gr(   c                 t   > [         TU ]  US9  U R                  R                  nUb  UR	                  5         g g )Nr  )rf   r  rw  toolbarrS   )r#   r  r  rx   s      r&   r  Figure.clear  s7    ^4 ++%%NN r(   c                    U R                  5       (       d  g U R                     U R                  U5      n UR                  SU R	                  5       S9  U R
                  (       a1  U R                  5       b    U R                  5       R                  U 5        U R                  R                  U5        [        R                  " XX R                  5        UR                  S5        SU l        [!        SU R"                  U5      R%                  5         S S S 5        g ! [         a     Nf = f! SU l        f = f! , (       d  f       g = f)NrK  r  F
draw_event)r  _render_lockr   r  r  r   r   executer?   r   r  r  r  ru   r  r"   r   rw  _processr  s      r&   r  Figure.draw  s	    !!,,X6G###H$,,.#A99!7!7!9!E..088>
 

)44G-C-CE $$X."
lDKK:CCE)  &  #
% sH   D4A D(7DAD(#,D4
D%"D($D%%D((	D11D44
Ec                     [        U 5      nUR                  5          U R                  U5        SSS5        g! , (       d  f       g= f)z
Draw the figure with no output.  Useful to get the final size of
artists that require a draw before their size is known (e.g. text).
N)r   _draw_disabledr  r   s     r&   draw_without_renderingFigure.draw_without_rendering  s2    
 !&$$&IIh '&&s	   7
Ac                 V    UR                  U R                  R                  5       5        g)z
Draw `.Artist` *a* only.
N)r  rw  r.  r:   s     r&   draw_artistFigure.draw_artist  s     	
t{{'')*r(   c                 *  > [         TU ]  5       nUR                  S5        UR                  SUS   5      US'   [        R
                  US'   SSKJn  U R                  R                  UR                  R                  R                  5       ;   a  SUS'   U$ )	Nrw  _original_dpir  __mpl_version__r   )_pylab_helpersT_restore_to_pylab)rf   rP   r9   r[  r   __version__
matplotlibr  rw  r  GcffigsrO   )r#   rT   r  rx   s      r&   rP   Figure.__getstate__  s    $&
 			( 		/5=Af $'??  	.;;."4"4"9"9"@"@"BB)-E%&r(   c                    UR                  S5      nUR                  SS5      nU[        R                  :w  a+  [        R                  " SU S[        R                   S35        Xl        [        U 5        U(       a  SS KJn  SS K	J
n  UR                  5       nU(       a  [        U5      S-   OSnUR                  5       nUR                  Xp5      n	UR                  R!                  U	5        UR#                  5         S	U l        g )
Nr  r  Fz.This figure was saved with matplotlib version z and loaded with z so may not function correctly.r   r   T)r9   r   r  r   r  __dict__r   matplotlib.pyplotpyplotmatplotlib._pylab_helpersr  get_fignumsrI   _get_backend_modnew_figure_manager_given_figurer  _set_new_active_managerdraw_if_interactiver"   )
r#   rT   versionrestore_to_pylabpltpylab_helpersallnumsr,  backendmgrs
             r&   rV   Figure.__setstate__  s    ))-. 99%8%@coo%@	 J"//NP  	+=oo'G&-#g,"1C**,G99#DC55c:##%
r(   c                 F   ^ U R                   R                  SU4S j5        g)z>Whenever the Axes state change, ``func(self)`` will be called.rt  c                    > T" U 5      $ r-   r^   )rh  funcs    r&   r   'Figure.add_axobserver.<locals>.<lambda>  s	    DIr(   N)ru  r  )r#   r  s    `r&   add_axobserverFigure.add_axobserver   s     	!!"68MNr(   )transparentc                  ^^ UR                  S[        R                  S   5        Uc  [        R                  S   n[        5        nU(       af  U4S jmU4S jmUR                  SS5        UR                  S	S5        U R                   H  nT" XE5        M     U R
                   H  nT" XF5        M     U R                  R                  " U40 UD6  SSS5        g! , (       d  f       g= f)
a  
Save the current figure as an image or vector graphic to a file.

Call signature::

  savefig(fname, *, transparent=None, dpi='figure', format=None,
          metadata=None, bbox_inches=None, pad_inches=0.1,
          facecolor='auto', edgecolor='auto', backend=None,
          **kwargs
         )

The available output formats depend on the backend being used.

Parameters
----------
fname : str or path-like or binary file-like
    A path, or a Python file-like object, or
    possibly some backend-dependent object such as
    `matplotlib.backends.backend_pdf.PdfPages`.

    If *format* is set, it determines the output format, and the file
    is saved as *fname*.  Note that *fname* is used verbatim, and there
    is no attempt to make the extension, if any, of *fname* match
    *format*, and no extension is appended.

    If *format* is not set, then the format is inferred from the
    extension of *fname*, if there is one.  If *format* is not
    set and *fname* has no extension, then the file is saved with
    :rc:`savefig.format` and the appropriate extension is appended to
    *fname*.

Other Parameters
----------------
transparent : bool, default: :rc:`savefig.transparent`
    If *True*, the Axes patches will all be transparent; the
    Figure patch will also be transparent unless *facecolor*
    and/or *edgecolor* are specified via kwargs.

    If *False* has no effect and the color of the Axes and
    Figure patches are unchanged (unless the Figure patch
    is specified via the *facecolor* and/or *edgecolor* keyword
    arguments in which case those colors are used).

    The transparency of these patches will be restored to their
    original values upon exit of this function.

    This is useful, for example, for displaying
    a plot on top of a colored background on a web page.

dpi : float or 'figure', default: :rc:`savefig.dpi`
    The resolution in dots per inch.  If 'figure', use the figure's
    dpi value.

format : str
    The file format, e.g. 'png', 'pdf', 'svg', ... The behavior when
    this is unset is documented under *fname*.

metadata : dict, optional
    Key/value pairs to store in the image metadata. The supported keys
    and defaults depend on the image format and backend:

    - 'png' with Agg backend: See the parameter ``metadata`` of
      `~.FigureCanvasAgg.print_png`.
    - 'pdf' with pdf backend: See the parameter ``metadata`` of
      `~.backend_pdf.PdfPages`.
    - 'svg' with svg backend: See the parameter ``metadata`` of
      `~.FigureCanvasSVG.print_svg`.
    - 'eps' and 'ps' with PS backend: Only 'Creator' is supported.

    Not supported for 'pgf', 'raw', and 'rgba' as those formats do not support
    embedding metadata.
    Does not currently support 'jpg', 'tiff', or 'webp', but may include
    embedding EXIF metadata in the future.

bbox_inches : str or `.Bbox`, default: :rc:`savefig.bbox`
    Bounding box in inches: only the given portion of the figure is
    saved.  If 'tight', try to figure out the tight bbox of the figure.

pad_inches : float or 'layout', default: :rc:`savefig.pad_inches`
    Amount of padding in inches around the figure when bbox_inches is
    'tight'. If 'layout' use the padding from the constrained or
    compressed layout engine; ignored if one of those engines is not in
    use.

facecolor : :mpltype:`color` or 'auto', default: :rc:`savefig.facecolor`
    The facecolor of the figure.  If 'auto', use the current figure
    facecolor.

edgecolor : :mpltype:`color` or 'auto', default: :rc:`savefig.edgecolor`
    The edgecolor of the figure.  If 'auto', use the current figure
    edgecolor.

backend : str, optional
    Use a non-default backend to render the file, e.g. to render a
    png file with the "cairo" backend rather than the default "agg",
    or a pdf file with the "pgf" backend rather than the default
    "pdf".  Note that the default backend is normally sufficient.  See
    :ref:`the-builtin-backends` for a list of valid backends for each
    file format.  Custom backends can be referenced as "module://...".

orientation : {'landscape', 'portrait'}
    Currently only supported by the postscript backend.

papertype : str
    One of 'letter', 'legal', 'executive', 'ledger', 'a0' through
    'a10', 'b0' through 'b10'. Only supported for postscript
    output.

bbox_extra_artists : list of `~matplotlib.artist.Artist`, optional
    A list of extra artists that will be considered when the
    tight bbox is calculated.

pil_kwargs : dict, optional
    Additional keyword arguments that are passed to
    `PIL.Image.Image.save` when saving the figure.

r  zsavefig.dpiNzsavefig.transparentc                   > U R                  UR                  R                  SSS95        UR                   H,  nU R                  UR                  R                  SSS95        M.     UR                   H  nT" X5        M     g Nr  )r  r  )enter_contextr   _cm_setr   rt   )
exit_stackr  r   
sub_subfig$_recursively_make_subfig_transparents       r&   r  <Figure.savefig.<locals>._recursively_make_subfig_transparent  s    ,,,,&, - @A %kk"00HH,,*0F - DE * '-nn
<&4 '5r(   c                   > U R                  UR                  R                  SSS95        UR                   H,  nU R                  UR                  R                  SSS95        M.     UR                   H  nT" X5        M     g r  )r  r   r  
child_axes)r  r   child_axchild_childax"_recursively_make_axes_transparents       r&   r  :Figure.savefig.<locals>._recursively_make_axes_transparent  s~    ,,((6V(LN$&MM"00$NN22*0F 3 DE %2 *,:&7 *7r(   r  r  r  )r   r   r   r   rt   r   rw  print_figure)	r#   fnamer  rw   stackr  r   r  r  s	          @@r&   savefigFigure.savefig  s    n 	%m!<=,,'<=K[E
4	7 !!+v6!!+v6"llF8G + ))B6uA $KK$$U5f5C [[s   BC
C(r   r~  c                    ^ ^^^^^^	^
 / m	/ m
U	U
UUUUU U4S jn[         R                  " T SS/X'5        T
 H  nUR                  5         M     T R                  R	                  5         T	$ )a  
Blocking call to interact with a figure.

Wait until the user clicks *n* times on the figure, and return the
coordinates of each click in a list.

There are three possible interactions:

- Add a point.
- Remove the most recently added point.
- Stop the interaction and return the points added so far.

The actions are assigned to mouse buttons via the arguments
*mouse_add*, *mouse_pop* and *mouse_stop*.

Parameters
----------
n : int, default: 1
    Number of mouse clicks to accumulate. If negative, accumulate
    clicks until the input is terminated manually.
timeout : float, default: 30 seconds
    Number of seconds to wait before timing out. If zero or negative
    will never time out.
show_clicks : bool, default: True
    If True, show a red cross at the location of each click.
mouse_add : `.MouseButton` or None, default: `.MouseButton.LEFT`
    Mouse button used to add points.
mouse_pop : `.MouseButton` or None, default: `.MouseButton.RIGHT`
    Mouse button used to remove the most recently added point.
mouse_stop : `.MouseButton` or None, default: `.MouseButton.MIDDLE`
    Mouse button used to stop input.

Returns
-------
list of tuples
    A list of the clicked (x, y) coordinates.

Notes
-----
The keyboard can also be used to select points in case your mouse
does not have one or more of the buttons.  The delete and backspace
keys act like right-clicking (i.e., remove last point), the enter key
terminates input and any other key (not already used by the window
manager) selects a point.
c                 z  > U R                   S:H  nU R                   S:H  nU(       a  U R                  T:X  d  U(       a,  U R                  S;   a  T
R                  R	                  5         GOU(       a  U R                  T:X  d  U(       ah  U R                  S;   aX  T(       aO  TR                  5         T(       a8  TR                  5       R                  5         T
R                  R                  5         GOU(       a  U R                  T:X  d  U(       a  U R                  b  U R                  (       a  TR                  U R                  U R                  45        [        R                  S[        T5      U R                  U R                  5        T(       a|  [        R                   R#                  U R                  /U R                  /SSS9nU R                  R%                  U5        TR                  U5        T
R                  R                  5         [        T5      T	:X  a"  T	S	:  a  T
R                  R	                  5         g g g )
Nr  r  )escapeenter)	backspacedeletezinput %i: %f, %f+rI  )markerr%  r   )r   buttonrG   rw  stop_event_loopr9   r<   r  inaxesr0  xdataydatar  r   r   r   ro   Line2Dadd_line)event	is_buttonis_keylineclicksmarks	mouse_add	mouse_pop
mouse_stopnr#   show_clickss       r&   handlerFigure.ginput.<locals>.handler  s   

&::IZZ#44F ellj8%))/B"B++-	 9		-D DJJL"		**,((*	 9		 5<<MM5;;"<=II0!&k5;;E""yy//}7:#  0  G--d3T*((*6{aAE++- %*r(   r  r  )r   blocking_input_loopr<   rw  r  )r#   r  timeoutr  r  r  r  r  markr  r  s   `` ````  @@r&   ginputFigure.ginput  sd    b  	.  	.D 	++'):;W	O DKKM r(   c                 t   ^ ^ SmUU 4S jn[         R                  " T SS/X5        Tc  S$ TR                  S:H  $ )z
Blocking call to interact with the figure.

Wait for user input and return True if a key was pressed, False if a
mouse button was pressed and None if no input was given within
*timeout* seconds.  Negative values deactivate *timeout*.
Nc                 >   > U mTR                   R                  5         g r-   )rw  r  )evr  r#   s    r&   r  *Figure.waitforbuttonpress.<locals>.handler  s    EKK'')r(   r  r  )r   r  r   )r#   r  r  r  s   `  @r&   waitforbuttonpressFigure.waitforbuttonpress  sI     	*
 	++'):;W	O }tI%**8I*IIr(   gHzG?r  rQ  rP  r;  c                4   [        XX4S9n U R                  5       nU R                  U5        UR                  U 5        Ub1  [	        U[         [
        45      (       d  [        R                  " S5        U R                  S5        g! U R                  S5        f = f)a  
Adjust the padding between and around subplots.

To exclude an artist on the Axes from the bounding box calculation
that determines the subplot parameters (i.e. legend, or annotation),
set ``a.set_in_layout(False)`` for that artist.

Parameters
----------
pad : float, default: 1.08
    Padding between the figure edge and the edges of subplots,
    as a fraction of the font size.
h_pad, w_pad : float, default: *pad*
    Padding (height/width) between edges of adjacent subplots,
    as a fraction of the font size.
rect : tuple (left, bottom, right, top), default: (0, 0, 1, 1)
    A rectangle in normalized figure coordinates into which the whole
    subplots area (including labels) will fit.

See Also
--------
.Figure.set_layout_engine
.pyplot.tight_layout
r  Nz&The figure layout has changed to tightr  )r   r   r  r  r@  r   r   r  )r#   r  rQ  rP  r;  r   previous_engines          r&   r  Figure.tight_layout  s    8 #suP		+"446O""6*NN4 *:"35L!M4 4 ""#KL""6*D""6*s   A&B B)r  rW  r  r  r  r  r  r(  r   r  r   r#  rw  r  r(  r  r   r"   r  r  r4  )NNr-   )Tr  )	r   r   NNNNNNF)NT))BrX   rY   rZ   r[   r\   	threadingRLockr  r  r  r3   r  r  r  r   r  r!  r  r   r  r  r)  r  r   r1  r8  r  r;  r   
deprecatedrC  r  rJ  rM  r  rT  r   r  ri  r7  r6  rq  rt  r  r  r|  r  r  r   r
   r  r  r  rP   rV   r  r  r   LEFTRIGHTMIDDLEr  r  r  r]   r  r  s   @r&   r  r  x	  sl   4 ??$L7
 |  !"$(| ||%&AIF#?*-X ' ' yyH< <* ]] '4" 8X+M
NCG 
__U(;!##&M 
__U(J!##, 
__	>33> 
__U(G!#,#,> BF;@__ _B(T-*&'	I"H" F  F6 +(6O -1 \6| "$$))$**%,,^@J( #'d$T &+ &+r(   r  c                    [        U S5      =(       a    [        R                  " U 5      (       + n[        R                  " S5      n[        R                  " S5      nU(       a  U R                  SS u  pEXE-  nOU n[
        R                  S   S   n[        R                  " Xv-  U45      nU[        S/X-  Q76 -  nU[        S/X-  Q76 -  n[        R                  " XU5      nU$ )	a"  
Calculate the width and height for a figure with a specified aspect ratio.

While the height is taken from :rc:`figure.figsize`, the width is
adjusted to match the desired aspect ratio. Additionally, it is ensured
that the width is in the range [4., 16.] and the height is in the range
[2., 16.]. If necessary, the default height is adjusted to ensure this.

Parameters
----------
arg : float or 2D array
    If a float, this defines the aspect ratio (i.e. the ratio height /
    width).
    In case of an array the aspect ratio is number of rows / number of
    columns, so that the array could be fitted in the figure undistorted.

Returns
-------
width, height : float
    The figure size in inches.

Notes
-----
If you want to create an Axes within the figure, that still preserves the
aspect ratio, be sure to create it with equal width and height. See
examples below.

Thanks to Fernando Perez for this function.

Examples
--------
Make a figure twice as tall as it is wide::

    w, h = figaspect(2.)
    fig = Figure(figsize=(w, h))
    ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
    ax.imshow(A, **kwargs)

Make a figure with the proper aspect for an array::

    A = rand(5, 3)
    w, h = figaspect(A)
    fig = Figure(figsize=(w, h))
    ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
    ax.imshow(A, **kwargs)
r\  )g      @g       @)      0@r  N   r  r   g      ?)
r   rB  isscalarr  r\  r   r   rX  rI   r7  )	rh  isarrayfigsize_minfigsize_maxnrnc	arr_ratio
fig_heightnewsizes	            r&   	figaspectr  A  s    ` c7#<BKK,<(<G ((:&K((<(K 2AG		 ./2J hh
.
;<G s31'/11G s31'/11G gggK8GNr(   )Fr\   
contextlibr   r9  r/   r  loggingnumbersr   r  numpyrB  r  r   r   r   r   r   matplotlib.artistr	   r
   r   matplotlib.backend_basesr   r   r   r   r   matplotlib._apir   matplotlib.cbookrj   matplotlib.colorbarr  r  matplotlib.imageimager  matplotlib.axesr   matplotlib.gridspecr   r   matplotlib.layout_enginer   r   r   r   matplotlib.legendr  r  matplotlib.patchesr   matplotlib.textr   matplotlib.transformsr   r   r   r   	getLoggerrX   r  r'   r*   r`   r  r  r  r  r^   r(   r&   <module>r     s   8 !         N N: :N N    " !   7  $ (  4 4 "
-6 -6`m - m -`A N
 N Nb E+Z E+ E+P&Mr(   