
    fMhN                    :   d dl mZ d dlZd dlmZ d dlmZmZmZ d dl	m
Z d dlmZ d dlZd dlmZmZ d dlmZmZ d dlmZmZ d dlmZmZ d d	lmZ erd d
lm Z  d dl!m"Z" d dl#m$Z$ d dl%m&Z& d dl'm(Z)  G d de          Z* G d de*          Z+ G d de*          Z,dS )    )annotationsN)pairwise)TYPE_CHECKINGAnycast)FillTypeLineType)convert_filledconvert_lines)as_fill_typeas_line_type)filled_to_mpl_pathslines_to_mpl_paths)Renderer)Sequence)Axes)Figure)	ArrayLikec                      e Zd ZU dZded<   ded<   ded<   	 	 	 	 	 	 dKdLdZdMdZdMdZdNdZ	 	 	 dOdPd*Z		 	 	 	 	 dQdRd2Z
	 	 	 	 dSdTd9Z	 	 dUdVd<ZdWdXd@ZdYdBZdMdCZdZd[dEZ	 	 	 	 d\d]dJZdS )^MplRenderera  Utility renderer using Matplotlib to render a grid of plots over the same (x, y) range.

    Args:
        nrows (int, optional): Number of rows of plots, default ``1``.
        ncols (int, optional): Number of columns of plots, default ``1``.
        figsize (tuple(float, float), optional): Figure size in inches, default ``(9, 9)``.
        show_frame (bool, optional): Whether to show frame and axes ticks, default ``True``.
        backend (str, optional): Matplotlib backend to use or ``None`` for default backend.
            Default ``None``.
        gridspec_kw (dict, optional): Gridspec keyword arguments to pass to ``plt.subplots``,
            default None.
    zSequence[Axes]_axesr   _figbool_want_tight   	   r   TNnrowsintncolsfigsizetuple[float, float]
show_framebackend
str | Nonegridspec_kwdict[str, Any] | NonereturnNonec                    |dd l }|                    |           |dddd}|||d<   nddi|d<   t          j        ||fi |\  | _        }	|	                                | _        |s| j        D ]}
|
                    d	           d| _        d S )
Nr   FT)r!   squeezesharexshareyr&   aspectequal
subplot_kwoff)	
matplotlibusepltsubplotsr   flattenr   axisr   )selfr   r    r!   r#   r$   r&   mplkwargsaxesaxs              [/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/contourpy/util/mpl_renderer.py__init__zMplRenderer.__init__,   s     $$$$GGG-4,0D"B "B"$/F=!!$,g#6F< ,ue>>v>>	4\\^^
 	j      c                \    t          | d          rt          j        | j                   d S d S )Nr   )hasattrr4   closer   r8   s    r=   __del__zMplRenderer.__del__H   s6    4   	!Idi     	! 	!r?   c                    | j         D ]0}t          |dd          r|                    d           d|_        1| j        r3t          | j                   dk    r| j                                         d S d S d S )N_need_autoscaleFT)tightr   )r   getattrautoscale_viewrF   r   lenr   tight_layoutr8   r<   s     r=   
_autoscalezMplRenderer._autoscaleL   s     * 	+ 	+Br,e44 +!!!---%*" 	%DJ! 3 3I""$$$$$	% 	% 3 3r?   r<   
Axes | intr   c                J    t          |t                    r| j        |         }|S N)
isinstancer   r   rL   s     r=   _get_axzMplRenderer._get_axW   s$    b# 	 BB	r?   r   C0ffffff?filledcpy.FillReturn	fill_typeFillType | strcolorstralphafloatc                    t          |          }|                     |          }t          ||          }t          j        ||dd|          }|                    |           d|_        dS )a  Plot filled contours on a single Axes.

        Args:
            filled (sequence of arrays): Filled contour data as returned by
                :meth:`~.ContourGenerator.filled`.
            fill_type (FillType or str): Type of :meth:`~.ContourGenerator.filled` data as returned
                by :attr:`~.ContourGenerator.fill_type`, or string equivalent
            ax (int or Maplotlib Axes, optional): Which axes to plot on, default ``0``.
            color (str, optional): Color to plot with. May be a string color or the letter ``"C"``
                followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the
                ``tab10`` colormap. Default ``"C0"``.
            alpha (float, optional): Opacity to plot with, default ``0.7``.
        noner   
facecolors
edgecolorslwr[   TN)r   rR   r   mcollectionsPathCollectionadd_collectionrF   )r8   rU   rW   r<   rY   r[   paths
collections           r=   rU   zMplRenderer.filled\   sx    * !++	\\"#FI66!0e1EK K K

*%%%!r?   black皙?xr   ypoint_colorquad_as_tri_alphac                   |                      |          }|                     ||          \  }}||d} |j        |||j        |j        fi | |dk    rd|ddddf         |ddddf         z   |ddddf         z   |ddddf         z   z  }	d|ddddf         |ddddf         z   |ddddf         z   |ddddf         z   z  }
||d<    |j        t	          j        |ddddf         |	|ddddf         f                              d          t	          j        |ddddf         |
|ddddf         f                              d          t	          j        |ddddf         |	|ddddf         f                              d          t	          j        |ddddf         |
|ddddf         f                              d          fi | ||                    ||||d	d
           d|_        dS )a  Plot quad grid lines on a single Axes.

        Args:
            x (array-like of shape (ny, nx) or (nx,)): The x-coordinates of the grid points.
            y (array-like of shape (ny, nx) or (ny,)): The y-coordinates of the grid points.
            ax (int or Matplotlib Axes, optional): Which Axes to plot on, default ``0``.
            color (str, optional): Color to plot grid lines, default ``"black"``.
            alpha (float, optional): Opacity to plot lines with, default ``0.1``.
            point_color (str, optional): Color to plot grid points or ``None`` if grid points
                should not be plotted, default ``None``.
            quad_as_tri_alpha (float, optional): Opacity to plot ``quad_as_tri`` grid, default 0.

        Colors may be a string color or the letter ``"C"`` followed by an integer in the range
        ``"C0"`` to ``"C9"`` to use a color from the ``tab10`` colormap.

        Warning:
            ``quad_as_tri_alpha > 0`` plots all quads as though they are unmasked.
        )rY   r[   r   g      ?Nr   r[   )   ro   o)rY   r[   markerrb   T)rR   _grid_as_2dplotTnpstackreshaperF   )r8   rj   rk   r<   rY   r[   rl   rm   r:   xmidymids              r=   gridzMplRenderer.gridy   s   8 \\"1%%1+05!A!A1ac13))&)))q  3B38qSbSz1Acrc122gJ>122qrr6JKD3B38qSbSz1Acrc122gJ>122qrr6JKD/F7OBG!CRC"H+tQqrr122vY788@@II!CRC"H+tQqrr122vY788@@II!ABBG*dAcrc122gJ788@@II!ABBG*dAcrc122gJ788@@II	 
    "GGAq5GKKK!r?         ?linescpy.LineReturn	line_typeLineType | str	linewidthc                    t          |          }|                     |          }t          ||          }t          j        |d|||          }|                    |           d|_        dS )aW  Plot contour lines on a single Axes.

        Args:
            lines (sequence of arrays): Contour line data as returned by
                :meth:`~.ContourGenerator.lines`.
            line_type (LineType or str): Type of :meth:`~.ContourGenerator.lines` data as returned
                by :attr:`~.ContourGenerator.line_type`, or string equivalent.
            ax (int or Matplotlib Axes, optional): Which Axes to plot on, default ``0``.
            color (str, optional): Color to plot lines. May be a string color or the letter ``"C"``
                followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the
                ``tab10`` colormap. Default ``"C0"``.
            alpha (float, optional): Opacity to plot lines with, default ``1.0``.
            linewidth (float, optional): Width of lines, default ``1``.
        r^   r_   TN)r   rR   r   rc   rd   re   rF   )	r8   r}   r   r<   rY   r[   r   rf   rg   s	            r=   r}   zMplRenderer.lines   sx    . !++	\\""5)44!0f9ES S S

*%%%!r?   z'ArrayLike | np.ma.MaskedArray[Any, Any]c                   t           j                            |          }|t           j        j        u rdS |                     |          }|                     ||          \  }}|                    ||         ||         d|           dS )a  Plot masked out grid points as circles on a single Axes.

        Args:
            x (array-like of shape (ny, nx) or (nx,)): The x-coordinates of the grid points.
            y (array-like of shape (ny, nx) or (ny,)): The y-coordinates of the grid points.
            z (masked array of shape (ny, nx): z-values.
            ax (int or Matplotlib Axes, optional): Which Axes to plot on, default ``0``.
            color (str, optional): Circle color, default ``"black"``.
        Nrq   )c)rv   magetmasknomaskrR   rs   rt   )r8   rj   rk   r   r<   rY   masks          r=   r   zMplRenderer.mask   s}    " u}}Q25<F\\"1%%1
$4#/////r?   Ffilenametransparentc                f    |                                   | j                            ||           dS )zSave plots to SVG or PNG file.

        Args:
            filename (str): Filename to save to.
            transparent (bool, optional): Whether background should be transparent, default
                ``False``.
        )r   N)rM   r   savefig)r8   r   r   s      r=   savezMplRenderer.save   s5     		(<<<<<r?   
io.BytesIOc                    |                                   t          j                    }| j                            |d           |                    d           |S )zhSave plots to an ``io.BytesIO`` buffer.

        Return:
            BytesIO: PNG image buffer.
        png)formatr   )rM   ioBytesIOr   r   seek)r8   bufs     r=   save_to_bufferzMplRenderer.save_to_buffer   sN     	jll	#e,,,
r?   c                T    |                                   t          j                     dS )zMShow plots in an interactive window, in the usual Matplotlib manner.
        N)rM   r4   showrC   s    r=   r   zMplRenderer.show   s#     	




r?   titlec                    |r,|                      |                              ||           dS |                      |                              |           dS )a  Set the title of a single Axes.

        Args:
            title (str): Title text.
            ax (int or Matplotlib Axes, optional): Which Axes to set the title of, default ``0``.
            color (str, optional): Color to set title. May be a string color or the letter ``"C"``
                followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the
                ``tab10`` colormap. Default is ``None`` which uses Matplotlib's default title color
                that depends on the stylesheet in use.
        )rY   N)rR   	set_title)r8   r   r<   rY   s       r=   r   zMplRenderer.title   s]      	.LL&&uE&:::::LL&&u-----r?   green.1ffmtquad_as_tric                   |                      |          }|                     ||          \  }}t          j        |          }|j        \  }}	t          |          D ]K}
t          |	          D ]9}|                    ||
|f         ||
|f         ||
|f         | dd|d           :L|rt          |dz
            D ]}
t          |	dz
            D ]}t          j        ||
|
dz   ||dz   f         t          j                  }t          j        ||
|
dz   ||dz   f         t          j                  }t          j        ||
|
dz   ||dz   f                   }|                    |||| dd|d           dS dS )a  Show ``z`` values on a single Axes.

        Args:
            x (array-like of shape (ny, nx) or (nx,)): The x-coordinates of the grid points.
            y (array-like of shape (ny, nx) or (ny,)): The y-coordinates of the grid points.
            z (array-like of shape (ny, nx): z-values.
            ax (int or Matplotlib Axes, optional): Which Axes to plot on, default ``0``.
            color (str, optional): Color of added text. May be a string color or the letter ``"C"``
                followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the
                ``tab10`` colormap. Default ``"green"``.
            fmt (str, optional): Format to display z-values, default ``".1f"``.
            quad_as_tri (bool, optional): Whether to show z-values at the ``quad_as_tri`` centers
                of quads.

        Warning:
            ``quad_as_tri=True`` shows z-values for all quads, even if masked.
        centerThavarY   clip_onr      dtypeN)	rR   rs   rv   asarrayshaperangetextmeanfloat64)r8   rj   rk   r   r<   rY   r   r   nynxjixxyyzzs                  r=   z_valueszMplRenderer.z_values  s   6 \\"1%%1JqMMBr 	3 	3A2YY 3 3!Q$1a4Qq!tWc*<*<h#T  3 3 3 33  	*2a4[[ * *r!t * *A1QqS5!AaC%<
CCCB1QqS5!AaC%<
CCCB1QqS5!AaC%<11BGGBr3MMh8SX$(  * * * *	*	* 	** *r?   )r   r   r   TNN)r   r   r    r   r!   r"   r#   r   r$   r%   r&   r'   r(   r)   )r(   r)   )r<   rN   r(   r   )r   rS   rT   )rU   rV   rW   rX   r<   rN   rY   rZ   r[   r\   r(   r)   )r   rh   ri   Nr   )rj   r   rk   r   r<   rN   rY   rZ   r[   r\   rl   r%   rm   r\   r(   r)   )r   rS   r|   r   )r}   r~   r   r   r<   rN   rY   rZ   r[   r\   r   r\   r(   r)   )r   rh   )rj   r   rk   r   r   r   r<   rN   rY   rZ   r(   r)   )F)r   rZ   r   r   r(   r)   )r(   r   )r   N)r   rZ   r<   rN   rY   r%   r(   r)   )r   r   r   F)rj   r   rk   r   r   r   r<   rN   rY   rZ   r   rZ   r   r   r(   r)   )__name__
__module____qualname____doc____annotations__r>   rD   rM   rR   rU   r{   r}   r   r   r   r   r   r    r?   r=   r   r      s          LLL '-"-1         8! ! ! !	% 	% 	% 	%    " " " " "B "&#$-" -" -" -" -"f " " " " "H 0 0 0 0 00	= 	= 	= 	= 	=
 
 
 
   . . . . .* !** ** ** ** ** ** **r?   r   c                  ,     e Zd ZdZ	 	 	 dd fdZ xZS )MplTestRendererzTest renderer implemented using Matplotlib.

    No whitespace around plots and no spines/ticks displayed.
    Uses Agg backend, so can only save to file/buffer, cannot call ``show()``.
    r   r   r   r   r    r!   r"   r(   r)   c                2   ddddddd}t                                          |||dd|           | j        D ]V}|                    d           |                    d           |                    g            |                    g            Wd| _        d S )	Ng{Gz?gGz?)leftrighttopbottomwspacehspaceTAgg)r#   r$   r&           F)superr>   r   set_xmarginset_ymargin
set_xticks
set_yticksr   )r8   r   r    r!   gridspecr<   	__class__s         r=   r>   zMplTestRenderer.__init__?  s     
 
 	5'dEx 	 	
 	
 	
 * 	 	BNN3NN3MM"MM" r?   )r   r   r   )r   r   r    r   r!   r"   r(   r)   )r   r   r   r   r>   __classcell__r   s   @r=   r   r   9  sW          '-	! ! ! ! ! ! ! ! ! ! !r?   r   c                       e Zd ZdZ	 	 	 	 d>d? fdZd@dZ	 	 	 	 	 	 	 	 dAdB fd)Z	 	 	 	 	 	 	 dCdD fd0Z	 	 dEdFd5Z	 	 dGdFd7Z		 	 	 dHdId=Z
 xZS )JMplDebugRendererzDebug renderer implemented using Matplotlib.

    Extends ``MplRenderer`` to add extra information to help in debugging such as markers, arrows,
    text, etc.
    r   r   Tr   r   r    r!   r"   r#   r   r(   r)   c                P    t                                          ||||           d S rP   )r   r>   )r8   r   r    r!   r#   r   s        r=   r>   zMplDebugRenderer.__init__`  s)     	w
;;;;;r?   r<   r   
line_startcpy.CoordinateArrayline_endrY   rZ   r[   r\   
arrow_sizec                   d||z   z  }||z
  }|t          j        t          j        ||                    z  }t          j        |d         |d          f          }	t          j        ||dz  |	z
  |z  z
  ||dz  |z  z   ||dz  |	z   |z  z
  f          }
|                    |
d d df         |
d d df         d||           d S )Ng      ?r   r   -r   r[   )rv   sqrtdotr   rw   rt   )r8   r<   r   r   rY   r[   r   midalongr   arrows              r=   _arrowzMplDebugRenderer._arrowi  s     :():%u--...
E!HuQxi01159u$j00%)J&&59u$j00
  
 	aaadU111a4[#eDDDDDr?   r   C1rT   rS   redri   rU   rV   rW   rX   rN   
line_color
line_alpharl   start_point_colorc                   t          |          }t                                          |||||           ||d S |                     |          }t	          ||t
          j                  }|t          | D ]\  }}|t          |          D ]\  }}|||         }|	                    |d d df         |d d df         ||           |
dk    rMt          |          }t          |dz
            D ]+}|                     |||         ||dz            |||
           ,|t          | D ]\  }}|t          j        |d         t                    }d||dd          dz
  <   |	|d d         }d||<   |	                    |d d df         |         |d d df         |         d||           |	:|	                    |d d df         |         |d d df         |         d|	|           d S d S )	Nr   r   r   r   ro   r   Frq   )r   r   rU   rR   r
   r   ChunkCombinedOffsetzipr   rt   rJ   r   r   rv   onesr   )r8   rU   rW   r<   rY   r[   r   r   rl   r   r   pointsoffsetsstartendxysnr   r   start_indicesr   s                       r=   rU   zMplDebugRenderer.filled}  sx    !++	vy"eU;;;+"5F\\"	83OPP !#&< 
b 
b>"*7"3"3 b bJE3 s+CGGC1Is111a4yJjGQQQ!C''HH!&qs b bA KKCFC!Hj*V`aaaab "#&< C C>wwr{$777&+WQRR[]#$0$+CRCLM*/D'111a4L&qqq!tT(:C;V`  b b b %0GGF111a4L71m9TVY/z  C C C #"C Cr?   r|   r}   r~   r   r   r   c
           
     :   t          |          }t                                          ||||||           |	dk    r|d S |                     |          }t	          ||t
          j                  }
t          rt          t          j
        |
          }
|	dk    rP|
D ]M}t          t          |          dz
            D ]+}|                     |||         ||dz            |||	           ,N||
D ]}d}t          |          }|i|                    |d         |d         d||           d}|d         d         |d         d         k    r#|d         d         |d         d         k    r|dz  }|                    |||df         |||df         d||           d S d S )	Nr   r   r   )r   r   )r   r   rq   r   ro   )r   r   r}   rR   r   r	   Separater   r   cpyLineReturn_Separater   rJ   r   rt   )r8   r}   r   r<   rY   r[   r   rl   r   r   separate_linesliner   start_index	end_indexr   s                  r=   r}   zMplDebugRenderer.lines  s    !++	eYE5)DDD!4F\\"&ui9JKK 	K!#"9>JJN& R Rs4yy{++ R RAKKDGT!A#YujQQQQR "& 	. 	.II	$0GGDJT
C;LTYGZZZ"#KAwqzT"Xa[00T!WQZ48A;5N5N!Q	[2A56[=RTU=U8VX[u  . . . . #"	. 	.r?   rj   r   rk   r   c                h   |                      |          }|                     ||          \  }}t          j        |          }|j        \  }}t          |          D ]U}t          |          D ]C}	|	||z  z   }
|                    |||	f         |||	f         t          |
          dd|d           DVd S )Nr   r   Tr   rR   rs   rv   r   r   r   r   rZ   )r8   rj   rk   r   r<   rY   r   r   r   r   quads              r=   point_numberszMplDebugRenderer.point_numbers  s     \\"1%%1JqMMBr 	& 	&A2YY & &1R4x!Q$1a4#d))EQV $  & & & &&	& 	&r?   bluec                   |                      |          }|                     ||          \  }}t          j        |          }|j        \  }}t          d|          D ]}t          d|          D ]}	|	||z  z   }
||dz
  |dz   |	dz
  |	dz   f                                         }||dz
  |dz   |	dz
  |	dz   f                                         }|                    ||t          |
          dd|d           d S )Nr   r   Tr   )	rR   rs   rv   r   r   r   r   r   rZ   )r8   rj   rk   r   r<   rY   r   r   r   r   r   ry   rz   s                r=   quad_numberszMplDebugRenderer.quad_numbers  s'    \\"1%%1JqMMBq" 	d 	dA1b\\ d d1R4x1QqS!A#ac')*//111QqS!A#ac')*//11dCII(xu^bcccc	d	d 	dr?   Nr   lower_levelupper_levelfloat | Nonec                   |                      |          }|                     ||          \  }}t          j        |          }|j        \  }}	t          |          D ]m}
t          |	          D ][}||
|f         }|	||k    rd}n||k    rd}nd}|                    ||
|f         ||
|f         t          |          dd|d           \nd S )Nr   r   r   r   r   Tr   r   )r8   rj   rk   r   r  r  r<   rY   r   r   r   r   r   z_levels                 r=   z_levelszMplDebugRenderer.z_levels  s     \\"1%%1JqMMBr 
	& 
	&A2YY 	& 	&q!tW*rK/?/?GG+%%GGG!Q$1a4#g,,6hV[ $  & & & &	&
	& 
	&r?   )r   r   r   T)
r   r   r    r   r!   r"   r#   r   r(   r)   )r<   r   r   r   r   r   rY   rZ   r[   r\   r   r\   r(   r)   )r   r   rT   rS   rT   rS   r   ri   )rU   rV   rW   rX   r<   rN   rY   rZ   r[   r\   r   rZ   r   r\   rl   rZ   r   rZ   r   r\   r(   r)   )r   rS   r|   r   rS   r   ri   )r}   r~   r   r   r<   rN   rY   rZ   r[   r\   r   r\   rl   rZ   r   rZ   r   r\   r(   r)   )r   r   )rj   r   rk   r   r   r   r<   rN   rY   rZ   r(   r)   )r   r   )Nr   r   )rj   r   rk   r   r   r   r  r\   r  r  r<   rN   rY   rZ   r(   r)   )r   r   r   r   r>   r   rU   r}   r   r  r  r   r   s   @r=   r   r   Z  s]         '-< < < < < < <E E E E0 !&3C 3C 3C 3C 3C 3C 3Cr !&&. &. &. &. &. &. &.Z & & & & &. d d d d d2 %)& & & & & & & & &r?   r   )-
__future__r   r   	itertoolsr   typingr   r   r   matplotlib.collectionscollectionsrc   matplotlib.pyplotpyplotr4   numpyrv   	contourpyr   r	   contourpy.convertr
   r   contourpy.enum_utilr   r   contourpy.util.mpl_utilr   r   contourpy.util.rendererr   collections.abcr   matplotlib.axesr   matplotlib.figurer   numpy.typingr   contourpy._contourpy
_contourpyr   r   r   r   r   r?   r=   <module>r     s   " " " " " " 				       + + + + + + + + + + - - - - - -           ( ( ( ( ( ( ( ( ; ; ; ; ; ; ; ; : : : : : : : : K K K K K K K K , , , , , , '(((((($$$$$$((((((&&&&&&&&&&&&[* [* [* [* [*( [* [* [*|! ! ! ! !k ! ! !B}& }& }& }& }&{ }& }& }& }& }&r?   