rL i'jdZddlmZmZmZddlmZmZmZddl m Z dZ GddejZ y ) z The inset module defines the InsetIndicator class, which draws the rectangle and connectors required for `.Axes.indicate_inset` and `.Axes.indicate_inset_zoom`. )_apiartist transforms)ConnectionPatch PathPatch Rectangle)Path)alpha edgecolor linestyle linewidthceZdZdZdZdfd ZdZdZdZdZ dZ d Z d Z d Z ed Zed ZdZej&dddZxZS)InsetIndicatora An artist to highlight an area of interest. An inset indicator is a rectangle on the plot at the position indicated by *bounds* that optionally has lines that connect the rectangle to an inset Axes (`.Axes.inset_axes`). .. versionadded:: 3.10 g(\@c n| | td||_|d|_|j}nd|_|\}}}}t ||f||fddi||_g|_t |!|j|tD]0} t|d| tj|j | 2y)aN Parameters ---------- bounds : [x0, y0, width, height], optional Lower-left corner of rectangle to be marked, and its width and height. If not set, the bounds will be calculated from the data limits of inset_ax, which must be supplied. inset_ax : `~.axes.Axes`, optional An optional inset Axes to draw connecting lines to. Two lines are drawn connecting the indicator box to the inset Axes on corners chosen so as to not overlap with the indicator box. zorder : float, default: 4.99 Drawing order of the rectangle and connector lines. The default, 4.99, is just below the default level of inset Axes. **kwargs Other keyword arguments are passed on to the `.Rectangle` patch. Nz3At least one of bounds or inset_ax must be suppliedTFclip_on_) ValueError _inset_ax_auto_update_bounds_bounds_from_inset_axr _rectangle _connectorssuper__init__ set_zorder_shared_propertiessetattrrgetp) selfboundsinset_axzorderkwargsxywidthheightprop __class__s V/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/inset.pyrzInsetIndicator.__init__s* >h.RS S! >'+D $//1F',D $$1eV#QFE6S5SFS  ' JD DAdV*fkk$//4&H I Jct|d||tj|jg|j||y)z` Helper function to set the same style property on the artist and its children. rN)rrsetprr)r r)vals r+_shared_setterzInsetIndicator._shared_setterJs8 $j#& T__8t'7'78$Dr,c(|jd|y)Nr r0)r r s r+ set_alphazInsetIndicator.set_alphaRs GU+r,c(|jd|y)z Set the edge color of the rectangle and the connectors. Parameters ---------- color : :mpltype:`color` or None r Nr2)r colors r+ set_edgecolorzInsetIndicator.set_edgecolorVs K/r,cL|jd||jd|y)z Set the edgecolor of the rectangle and the connectors, and the facecolor for the rectangle. Parameters ---------- c : :mpltype:`color` r facecolorNr2)r cs r+ set_colorzInsetIndicator.set_color`s$ K+ K+r,c(|jd|y)z Set the linewidth in points of the rectangle and the connectors. Parameters ---------- w : float or None rNr2)r ws r+ set_linewidthzInsetIndicator.set_linewidthls K+r,c(|jd|y)a Set the linestyle of the rectangle and the connectors. ========================================== ================= linestyle description ========================================== ================= ``'-'`` or ``'solid'`` solid line ``'--'`` or ``'dashed'`` dashed line ``'-.'`` or ``'dashdot'`` dash-dotted line ``':'`` or ``'dotted'`` dotted line ``'none'``, ``'None'``, ``' '``, or ``''`` draw nothing ========================================== ================= Alternatively a dash tuple of the following form can be provided:: (offset, onoffseq) where ``onoffseq`` is an even length tuple of on and off ink in points. Parameters ---------- ls : {'-', '--', '-.', ':', '', (offset, on-off-seq), ...} The line style. r Nr2)r lss r+ set_linestylezInsetIndicator.set_linestylevs2 K,r,c|jj}|jj}|d|d|d|dz |d|dz fS)Nrr)rget_xlimget_ylim)r xlimylims r+rz$InsetIndicator._bounds_from_inset_axsW~~&&(~~&&(Qa$q'DG"3T!WtAw5FGGr,c T|jj\}}|jj}|jj}|jxsdgdz}t gd|D]7\}}|\}} |j jjrd|z }|j jjrd| z } |||zz|| |zzf} |t||jj| |j jd|j|j|j |j" } |jj%| ||_| |_|jj|_|j j|_:w|jj/} | j1|j3dj4} t6j8j;||||j1|jj=}|j>| j>k}|j@| j@k}|jB| jBk}|jD| jDk}|jdjG||z |jdjG||k(|jd jG||k(|jd jG||z yy) N))rr)rr)rr)rrr-) xyAcoordsAxyBcoordsB arrowstyler r r rF)rootr)$rget_xy get_width get_heightrzipaxesxaxis get_invertedyaxisrr transAxes transData _edgecolor get_alpha _linestyle _linewidthappendxy1xy2coords1coords2 get_position transformed get_figuretransSubfigurerBbox from_bounds get_transformx0x1y0y1 set_visible)r r%r&r'r(existing_connectors xy_inset_axexistingexeyxy_datapposbboxinsrectbboxrkrlrmrns r+_update_connectorsz!InsetIndicator._update_connectorss'')A))+++-"..<4&1*&))I)<&> 7 !K !FByy++-Vyy++-V"u*na"v+o5G$#T^^-E-E)<)<""ooT^^5E"oo J   ''* + & #'>>#;#; #'99#6#6 7 7:  ..--/Coodoo5o&A&P&PQG!221aGSS--/1Hwzz)Bwzz)Bwzz)Bwzz)B   Q  + +BG 4   Q  + +B"H 5   Q  + +B"H 5   Q  + +BG 4 r,c|jS)z"`.Rectangle`: the indicator frame.)rr s r+ rectanglezInsetIndicator.rectanglesr,c|jy|jr)|jj|j |j t |jS)ai 4-tuple of `.patches.ConnectionPatch` or None The four connector lines connecting to (lower_left, upper_left, lower_right upper_right) corners of *inset_ax*. Two lines are set with visibility to *False*, but the user can set the visibility to True if the automatic choice is not deemed correct. N)rrr set_boundsrrztuplerr|s r+ connectorszInsetIndicator.connectorssR >> !   # # OO & &t'A'A'C D !T%%&&r,cg}|jxsgD]}|jsd}tD]N}tj|j |tj||k7s;|j |d}n|rp|j||r|j g|z}|Dcgc]/}|jj|j1}}tj|} t| } | j|j | jt!j"| j |y|j j |ycc}w)NFT)r get_visiblerrrrdrawr_rjtransform_pathget_pathr make_compound_pathr update_from set_transformrIdentityTransform) r rendererconn_same_styleconndrawnsartistsapathspathrvs r+rzInsetIndicator.draws6OO)r 1D!+A{{4??A6&++dA:NN (+ $ #**40 1 '/9GMTUQ__&55ajjlCUEU**E2D$A MM$// * OOJ88: ; FF8   X&Vs,4E+z3.10zSince Matplotlib 3.10 indicate_inset_[zoom] returns a single InsetIndicator artist with a rectangle property and a connectors property. From 3.12 it will no longer be possible to unpack the return value into two elements.)messagec8|j|jg|S)N)rr)r keys r+ __getitem__zInsetIndicator.__getitem__s1#66r,)NNN)__name__ __module__ __qualname____doc__r#rr0r3r6r:r=r@rrzpropertyr}rrr deprecatedr __classcell__)r*s@r+rrsF.J`E,0 ,,-6H 25h'' $'LT__35 7 5 7r,rN)rrrrmatplotlib.patchesrrr matplotlib.pathr rArtistrr,r+rs6 '&DD F7V]]7r,