WL i|N&ddlmZddlZddlmZddlmZmZmZddl m Z ddl m ZddlZddlmZmZddlmZmZddlmZmZddlmZmZdd lmZerdd lm Z dd l!m"Z"dd l#m$Z$dd l%m&Z&ddl'm(Z)GddeZ*Gdde*Z+Gdde*Z,y)) annotationsN)pairwise) TYPE_CHECKINGAnycast)FillTypeLineType)convert_filled convert_lines) as_fill_type as_line_type)filled_to_mpl_pathslines_to_mpl_paths)Renderer)Sequence)Axes)Figure) ArrayLikecteZdZUdZded<ded<ded< d dd Zdd Zdd Zdd Z d dd Z d ddZ d ddZ d d!dZ d"d#dZ d$dZddZd%d&dZ d' d(dZy)) MplRendereraUtility 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. zSequence[Axes]_axesr_figbool _want_tightNc|ddl}|j||dddd}|||d<nddi|d<tj||fi|\|_} | j |_|s"|j D]} | jd d|_y) NrFT)figsizesqueezesharexsharey gridspec_kwaspectequal subplot_kwoff) matplotlibusepltsubplotsrflattenraxisr) selfnrowsncolsr show_framebackendr mplkwargsaxesaxs a/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/contourpy/util/mpl_renderer.py__init__zMplRenderer.__init__,s   $ GGG -4,0D"B  "$/F= !$,g#6F< ,,ue>v> 4\\^ jj   c\t|dr tj|jyy)Nr)hasattrr'closerr+s r4__del__zMplRenderer.__del__Hs! 4 IIdii  !r6c|jD])}t|dds|jdd|_+|jr4t |jdkDr|j jyyy)N_need_autoscaleFT)tight)rgetattrautoscale_viewr=rlenr tight_layoutr+r3s r4 _autoscalezMplRenderer._autoscaleLso** +Br,e4!!!-%*" +   DJJ! 3 II " " $!4 r6cDt|tr|j|}|SN) isinstanceintrrDs r4_get_axzMplRenderer._get_axWs b# BB r6ct|}|j|}t||}tj||dd|}|j |d|_y)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 edgecolorslwalphaTN)r rJr mcollectionsPathCollectionadd_collectionr=)r+filled fill_typer3colorrQpaths collections r4rUzMplRenderer.filled\sZ*!+ \\" #FI6!00 e1EK  *%!r6c |j|}|j||\}}||d}|j|||j|jfi||dkDr[d|ddddf|ddddfz|ddddfz|ddddfzz} d|ddddf|ddddfz|ddddfz|ddddfzz} ||d<|jt j |ddddf| |ddddffj dt j |ddddf| |ddddffj dt j |ddddf| |ddddffj dt j |ddddf| |ddddffj dfi|||j||||d d d |_y) aPlot 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. )rWrQrg?Nr?rQ)r[o)rWrQmarkerrPT)rJ _grid_as_2dplotTnpstackreshaper=) r+xyr3rWrQ point_colorquad_as_tri_alphar1xmidymids r4gridzMplRenderer.gridys.8\\" 1%1+05!A1acc133)&) q 3B38qSbSz1Acrc12gJ>12qr6JKD3B38qSbSz1Acrc12gJ>12qr6JKD/F7O BGG!CRC"H+tQqr12vY78@@I!CRC"H+tQqr12vY78@@I!ABG*dAcrc12gJ78@@I!ABG*dAcrc12gJ78@@I       " GGAq 5G K!r6ct|}|j|}t||}tj|d|||}|j |d|_y)aWPlot 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``. rLrMTN)r rJrrRrSrTr=) r+lines line_typer3rWrQ linewidthrXrYs r4rmzMplRenderer.linessZ.!+ \\" "5)4!00 f9ES  *%!r6ctjj|}|tjjury|j |}|j ||\}}|j ||||d|y)aPlot 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"``. Nr])c)rbmagetmasknomaskrJr_r`)r+rerfzr3rWmasks r4rvzMplRenderer.masksi"uu}}Q 255<<   \\" 1%1 $4#/r6c^|j|jj||y)zSave plots to SVG or PNG file. Args: filename (str): Filename to save to. transparent (bool, optional): Whether background should be transparent, default ``False``. ) transparentN)rErsavefig)r+filenamerxs r4savezMplRenderer.saves%  ( } t | D].} |j || | f|| | f|| | f|ddd|d0@|rt |dz D]} t | dz D]} tj|| | dz| | dzftj} tj|| | dz| | dzftj} tj|| | dz| | dzf}|j | | ||ddd|dyy) aShow ``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. centerThavarWclip_onr?dtypeN) rJr_rbasarrayshaperangetextmeanfloat64)r+rerfrur3rWfmt quad_as_trinynxjixxyyzzs r4z_valueszMplRenderer.z_values s6\\" 1%1 JJqMBr 3A2Y 3!Q$1a4Qq!tWcU FOh#T3 3 3 2a4[ *r!t*A1QqS5!AaC%< CB1QqS5!AaC%< CB1QqS5!AaC%<1BGGBr3%pjh8SX$(* * * r6)r?r? rTNN)r,rIr-rIrtuple[float, float]r.rr/ str | Noner zdict[str, Any] | NonereturnNone)rr)r3 Axes | intrr)rC0ffffff?) rUcpy.FillReturnrVFillType | strr3rrWstrrQfloatrr)rblack皙?Nr)rerrfrr3rrWrrQrrgrrhrrr)rr?r?)rmcpy.LineReturnrnLineType | strr3rrWrrQrrorrr)rr) rerrfrruz'ArrayLike | np.ma.MaskedArray[Any, Any]r3rrWrrr)F)rzrrxrrr)rz io.BytesIO)rN)rrr3rrWrrr)rgreenz.1fF)rerrfrrurr3rrWrrrrrrr)__name__ __module__ __qualname____doc____annotations__r5r;rErJrUrkrmrvr{rrrrr6r4rrsJ   L'-"-1   %      +   8! % """"  "  "  " "B"&#$-" -" -"  -"  -"  -" -"!-" -"f""""  "  "  "" "H 0 0 0 3 0  0  0 00 =  .*!** ** **  **  **  ****** **r6rc:eZdZdZ d dfd ZxZS)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()``. cddddddd}t||||dd||jD]F}|jd|j d|j g|j gHd|_y) Ng{Gz?gGz?)leftrighttopbottomwspacehspaceTAgg)r.r/r F)superr5r set_xmargin set_ymargin set_xticks set_yticksr)r+r,r-rgridspecr3 __class__s r4r5zMplTestRenderer.__init__?s    5'dEx  ** B NN3  NN3  MM"  MM"    !r6)r?r?r)r,rIr-rIrrrr)rrrrr5 __classcell__rs@r4rr9sC'- !!!% !  !!r6rcdeZdZdZ d d fd Z d dZ d d fd Z d dfd Z d ddZ d ddZ d ddZ xZ S)MplDebugRendererzDebug renderer implemented using Matplotlib. Extends ``MplRenderer`` to add extra information to help in debugging such as markers, arrows, text, etc. c*t|||||yrG)rr5)r+r,r-rr.rs r4r5zMplDebugRenderer.__init__`s w ;r6cld||zz}||z }|tjtj||z}tj|d|d f} tj||dz| z |zz ||dz|zz||dz| z|zz f} |j | dddf| dddfd||y)Ng?r?r-rqrQ)rbsqrtdotrrcr`) r+r3 line_startline_endrWrQ arrow_sizemidalongrarrows r4_arrowzMplDebugRenderer._arrowis:():% u-.. E!HuQxi01 59u$j0 0 %)J& & 59u$j0 0   ad U1a4[#eDr6c t|}t| |||||||y|j|}t ||t j }|t|D]\} } |  t| D]p\} }| | |}|j|dddf|dddf||| dkDs4t|}t|dz D]!}|j|||||dz||| #r|t|D]\} } |  tj| dt}d|| dddz <| | dd}d||<|j| dddf|| dddf|d||| k|j| dddf| dddf|d| |yy) Nrr?rrr[rFr])r rrUrJr rChunkCombinedOffsetziprr`rBrrrbonesr)r+rUrVr3rWrQ line_color line_alphargstart_point_colorrpointsoffsetsstartendxysnrrv start_indicesrs r4rUzMplDebugRenderer.filled}s!+  vy"eU;  +"5  \\"  83O3OP  !#&< b>"*7"3bJE3 s+CGGC1Is1a4yJjGQ!C'H!&qsbA KKCFC!Hj*V`ab b b  "#&< C>wwwr{$7&+WQR[]#$0$+CRLM*/D'1a4L&q!t T(:C;V`b%0GGF1a4L71m9TVY/zC C #r6c ~t|}t| ||||||| dk(r|y|j|}t ||t j } trttj| } | dkDrB| D]=} tt| dz D]!} |j|| | | | dz||| #?|| D]z} d} t| }|E|j| d| dd||d} | dd| ddk(r| dd| ddk(r|dz}|j| | |df| | |dfd|||yy) Nrr?r)rr)rr?r]rr[)r rrmrJr r SeparaterrcpyLineReturn_SeparaterrBrr`)r+rmrnr3rWrQrorgrrseparate_linesliner start_index end_indexrs r4rmzMplDebugRenderer.liness!+   eYE5)D  !4  \\" &ui9J9JK !#"9"9>JN  & Rs4y{+RAKKDGT!A#YujQR R  "& . I $0GGDJT C;LTYGZ"#KAwqzT"Xa[0T!WQZ48A;5N!Q [2A56[=RTU=U8VX[u. . #r6c >|j|}|j||\}}tj|}|j\}}t |D]E}t |D]5} | ||zz} |j ||| f||| ft| dd|d7Gy)NrrTrrJr_rbrrrrr) r+rerfrur3rWrrrrquads r4 point_numberszMplDebugRenderer.point_numberss\\" 1%1 JJqMBr &A2Y &1R4x!Q$1a4#d)EQV $& & &r6c |j|}|j||\}}tj|}|j\}}t d|D]}t d|D]u} | ||zz} ||dz |dz| dz | dzfj } ||dz |dz| dz | dzfj } |j| | t| dd|dwy)Nr?rTr) rJr_rbrrrrrr) r+rerfrur3rWrrrrrrirjs r4 quad_numberszMplDebugRenderer.quad_numberss\\" 1%1 JJqMBq" dA1b\ d1R4x1QqS!A#ac')*//11QqS!A#ac')*//1dCI(xu^bc  d dr6c d|j|}|j||\}}tj|}|j\}} t |D]X} t | D]H} || | f} || |kDrd} n | |kDrd} nd} |j || | f|| | ft| dd|dJZy)Nrr?rrrTrr)r+rerfru lower_level upper_levelr3rWrrrrrz_levels r4z_levelszMplDebugRenderer.z_levelss\\" 1%1 JJqMBr &A2Y &q!tW*rK/?G+%GG!Q$1a4#g,6hV[ $& & &r6)r?r?rT) r,rIr-rIrrr.rrr)r3rrcpy.CoordinateArrayrrrWrrQrrrrr)rC1rrrrredr)rUrrVrr3rrWrrQrrrrrrgrrrrrrr)rrrr?rrr)rmrrnrr3rrWrrQrrorrgrrrrrrr)rr) rerrfrrurr3rrWrrr)rblue)Nrr)rerrfrrurrrrz float | Noner3rrWrrr) rrrrr5rrUrmrrrrrs@r4rrZs'- <<<% <  <  <E E(E& E  E  EE E0!&3C3C"3C  3C  3C  3C3C3C3C3C3C 3Cr!&&.&."&.  &.  &.  &.&.&.&.&. &.Z & & &  &  &  & &. d d d  d  d  d d2%)& & &  &  & " & && &r6r)- __future__rr itertoolsrtypingrrrmatplotlib.collections collectionsrRmatplotlib.pyplotpyplotr'numpyrb contourpyrr contourpy.convertr r contourpy.enum_utilr r contourpy.util.mpl_utilrrcontourpy.util.rendererrcollections.abcrmatplotlib.axesrmatplotlib.figurer numpy.typingrcontourpy._contourpy _contourpyrrrrrr6r4rsh" ++-(;:K,($(&&[*([*|!k!B}&{}&r6