rL iqdZddlmZddlmZmZmZddlmZm Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZddlZddlZddlmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'ddl(m)Z)dd l*m+Z+dd l,m-Z-dd l.m/Z/dd l0m1Z1dd l2m3Z3ddl4m5Z5ddl6m7Z7m8Z8ejre:Z;dddddddddddddddZd!Z?Gd"d#Z@Gd$d%ZAGd&d'ZBGd(d)ZCGd*d+eCZDGd,d-eCZEGd.d/eCZFGd0d1eCZGGd2d3e ZHGd4d5eGZIGd6d7eCZJGd8d9eGZKd:ZLd;ZMdRd<ZNd=ZOd>ZPed?ZQGd@dAZRdSdBZSdSdCZTGdDdEeUZVGdFdGZWejZXGdHdIeYeZZGdJdKZ[GdLdMZ\GdNdOZ]GdPdQe]Z^y)Ta Abstract base classes define the primitives that renderers and graphics contexts must implement to serve as a Matplotlib backend. `RendererBase` An abstract base class to handle drawing/rendering operations. `FigureCanvasBase` The abstraction layer that separates the `.Figure` from the backend specific details like a user interface drawing area. `GraphicsContextBase` An abstract base class that provides color, line styles, etc. `Event` The base class for all of the Matplotlib event handling. Derived classes such as `KeyEvent` and `MouseEvent` store the meta data like keys and buttons pressed, x and y locations in pixel and `~.axes.Axes` coordinates. `ShowBase` The base class for the ``Show`` class of each interactive backend; the 'show' callable is then set to ``Show.__call__``. `ToolContainerBase` The base class for the Toolbar class of each interactive backend. ) namedtuple) ExitStackcontextmanager nullcontext)EnumIntEnumN)WeakKeyDictionary) _api backend_toolscbookcolors _docstringtext _tight_bbox transformswidgetsis_interactivercParams)Gcf) ToolManager) _setattr_cm)ConstrainedLayoutEngine)Path) TexManager)Affine2D) JoinStyleCapStylezEncapsulated Postscriptz Joint Photographic Experts GroupzPortable Document FormatzPGF code for LaTeXzPortable Network Graphics PostscriptzRaw RGBA bitmapzScalable Vector GraphicszTagged Image File FormatzWebP Image Format)epsjpgjpegpdfpgfpngpsrawrgbasvgsvgztiftiffwebpzmatplotlib.backends.backend_pszmatplotlib.backends.backend_aggzmatplotlib.backends.backend_pdfzmatplotlib.backends.backend_pgfzmatplotlib.backends.backend_svgc0|d}|t|<|t|<y)a$ Register a backend for saving to a given file format. Parameters ---------- format : str File extension backend : module string or canvas class Backend for handling file output description : str, default: "" Description of the file type. N)_default_backends_default_filetypes)formatbackend descriptions ^/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/backend_bases.pyregister_backendr5as% 'f!,vc|tvryt|}t|tr(tj|j }|t|<|S)zv Return the registered default canvas for given file format. Handles deferred import of required backend. N)r/ isinstancestr importlib import_module FigureCanvas)r1 backend_classs r4get_registered_canvas_classr>tsK &&%f-M-%!// >KK $1&! r6ceZdZdZfdZd!dZdZd!dZ d!dZdZ d Z d Z d Z d Z d ZdZd!dZdZdZdddZd"dZdZdZdZdZdZdZdZdZdZdZdZd Z xZ!S)# RendererBasea An abstract base class to handle drawing/rendering operations. The following methods must be implemented in the backend for full functionality (though just implementing `draw_path` alone would give a highly capable backend): * `draw_path` * `draw_image` * `draw_gouraud_triangles` The following methods *should* be implemented in the backend for optimization reasons: * `draw_text` * `draw_markers` * `draw_path_collection` * `draw_quad_mesh` c~t|d|_tj|_d|_d|_y)NrF)super__init__ _texmanagerr TextToPath _text2path _raster_depth _rasterizing)self __class__s r4rCzRendererBase.__init__s4 //+!r6Ncy)zz Open a grouping element with label *s* and *gid* (if set) as id. Only used by the SVG renderer. N)rIsgids r4 open_groupzRendererBase.open_groupr6cy)zb Close a grouping element with label *s*. Only used by the SVG renderer. NrLrIrMs r4 close_groupzRendererBase.close_grouprPr6ct)z?Draw a `~.path.Path` instance using the given affine transform.NotImplementedError)rIgcpath transformrgbFaces r4 draw_pathzRendererBase.draw_paths!!r6c |j|dD]R\}}t|s|dd\} } |j|||tjj | | z|Ty)aB Draw a marker at each of *path*'s vertices (excluding control points). The base (fallback) implementation makes multiple calls to `draw_path`. Backends may want to override this method in order to draw the marker only once and reuse it multiple times. Parameters ---------- gc : `.GraphicsContextBase` The graphics context. marker_path : `~matplotlib.path.Path` The path for the marker. marker_trans : `~matplotlib.transforms.Transform` An affine transform applied to the marker. path : `~matplotlib.path.Path` The locations to draw the markers. trans : `~matplotlib.transforms.Transform` An affine transform applied to the path. rgbFace : :mpltype:`color`, optional F)simplifyN) iter_segmentslenr[rr translate) rIrW marker_path marker_transrXtransrZverticescodesxys r4 draw_markerszRendererBase.draw_markerssr. $11%%1H (OHe8}}1r;+)224>>q!D E&( (r6c |j|||}|j|t|||||| | | | | D]M\}}}}}|\}}|dk7s|dk7r"|j}|j |||j ||||Oy)a Draw a collection of *paths*. Each path is first transformed by the corresponding entry in *all_transforms* (a list of (3, 3) matrices) and then by *master_transform*. They are then translated by the corresponding entry in *offsets*, which has been first transformed by *offset_trans*. *facecolors*, *edgecolors*, *linewidths*, *linestyles*, and *antialiased* are lists that set the corresponding properties. *offset_position* is unused now, but the argument is kept for backwards compatibility. The base (fallback) implementation makes multiple calls to `draw_path`. Backends may want to override this in order to render each set of path data only once, and then reference that path multiple times with the different offsets, colors, styles etc. The generator methods `_iter_collection_raw_paths` and `_iter_collection` are provided to help with (and standardize) the implementation across backends. It is highly recommended to use those generators, so that changes to the behavior of `draw_path_collection` can be made globally. rN)_iter_collection_raw_paths_iter_collectionlistfrozenrar[)rIrWmaster_transformpathsall_transformsoffsets offset_trans facecolors edgecolors linewidths linestyles antialiasedsurlsoffset_positionpath_idsxoyopath_idgc0rZrXrYs r4draw_path_collectionz!RendererBase.draw_path_collections6223C38.J.2-B-BDNG\J JdO.5 : )BGS'&OD)Qw"'&,,. ##B+ NN3i 9 :r6c ddlm} | j|} | |} tj|j gt } |j||| g|||| | g| gdgd S)z Draw a quadmesh. The base (fallback) implementation converts the quadmesh to paths and then calls `draw_path_collection`. r)QuadMeshNscreen)matplotlib.collectionsr_convert_mesh_to_pathsnparray get_linewidthfloatr)rIrWro meshWidth meshHeight coordinatesrr offsetTransrt antialiasedrurrprvs r4draw_quad_meshzRendererBase.draw_quad_meshst 4// <  #JXXr//12E: ((  %Wk:  B vxI Ir6ct)a Draw a series of Gouraud triangles. Parameters ---------- gc : `.GraphicsContextBase` The graphics context. triangles_array : (N, 3, 2) array-like Array of *N* (x, y) points for the triangles. colors_array : (N, 3, 4) array-like Array of *N* RGBA colors for each point of the triangles. transform : `~matplotlib.transforms.Transform` An affine transform to apply to the points. rU)rIrWtriangles_array colors_arrayrYs r4draw_gouraud_trianglesz#RendererBase.draw_gouraud_triangless "!r6c#Kt|}t|}t||}|dk(rytj}t |D]&}|||z} |rt |||z}| ||zf(yw)a Helper method (along with `_iter_collection`) to implement `draw_path_collection` in a memory-efficient manner. This method yields all of the base path/transform combinations, given a master transform, a list of paths and list of transforms. The arguments should be exactly what is passed in to `draw_path_collection`. The backend should take each yielded path and transform and create an object that can be referenced (reused) later. rN)r`maxrIdentityTransformranger) rIrorprqNpaths NtransformsNrYirXs r4rkz'RendererBase._iter_collection_raw_paths"sU.)  $ Q; 002 q 5AV$D$^A O%DE  $444 4  5sA2A4ct|}|dk(s t|t|cxk(rdk(rynyt|t|}t|t|}||zdz |zS)a Compute how many times each raw path object returned by `_iter_collection_raw_paths` would be used when calling `_iter_collection`. This is intended for the backend to decide on the tradeoff between using the paths in-line and storing them once and reusing. Rounds up in case the number of uses is not the same for every path. r)r`r) rIrprqrrrtrur Npath_idsrs r4_iter_collection_uses_per_pathz+RendererBase._iter_collection_uses_per_path?siU Q;#j/S_AABN 34  3w< (I !i//r6c #$Kt|} t|} t| | }t|}t|}t|}t|}t| }|dk(r|dk(s| dk(ry|j}|j|dd}||}||j |d}||}||}||}||}|| }|| } |dk(r|j dt jt|||||||| |D]\}\}}} }!}"}#}$}%tj|rtj|s:|r]|r|j |"|r|j|#t|!dk(r|!ddk(r|j dn|j|!| t| dk(r | ddk(rd} |j|$|r|j|%||||| f|jyw) a Helper method (along with `_iter_collection_raw_paths`) to implement `draw_path_collection` in a memory-efficient manner. This method yields all of the path, offset and graphics context combinations to draw the path collection. The caller should already have looped over the results of `_iter_collection_raw_paths` to draw this collection. The arguments should be the same as that passed into `draw_path_collection`, with the exception of *path_ids*, which is a list of arbitrary objects that the backend will use to reference one of the paths created in the `_iter_collection_raw_paths` stage. Each yielded result is of the form:: xo, yo, path_id, gc, rgbFace where *xo*, *yo* is an offset; *path_id* is one of the elements of *path_ids*; *gc* is a graphics context and *rgbFace* is a color to use for filling the path. rNclt|rtj|Stj|SN)r` itertoolscyclerepeat)seqdefaults r4cycle_or_defaultz7RendererBase._iter_collection..cycle_or_defaultxs,,/HIOOC( 4"))'2 4r6)rrr)r`rnew_gccopy_propertiesrY set_linewidthrisliceziprisfinite set_dashesset_foregroundset_antialiasedset_urlrestore)&rIrWr{rrrsrtrurvrwrxryrzrNoffsetsr Nfacecolors Nedgecolors Nlinewidths NlinestylesNurlsrrpathidstoffsetsfcsecslwslssaaspathidr|r}fceclwlsaaurls& r4rlzRendererBase._iter_collectionPs 2Xw<  !*o *o *o *o D  1 !1fk kkm B 4 #8,#L$:$:7$CVLz*z*z*z*|,% !    c "9B9I9IGXsCc3Eq:J * 5FHRb"b"b#KKO B%%b)"CNNB'r7az-RendererBase._draw_disabled..rPr6)dirr@ startswithr)rI meth_nameno_opss r4_draw_disabledzRendererBase._draw_disabledsZ!. $$W- == 3 3  4*6** s Ar)FN)"__name__ __module__ __qualname____doc__rCrOrSr[rirrrrkrrlrrrrrrrrrrrrrrrrrr  __classcell__rJs@r4r@r@s&"  " %)(>+:ZI*"$5:0"L\"@;?H. BD;6> %(    +r6r@c0eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZej.dZdZdZdZd(dZej.dZdZdZdZ dZ!dZ"dZ#d)d Z$d!Z%d"Z&d#Z'd$Z(d%Z)d*d'Z*y&)+r z=An abstract base class that provides color, line styles, etc.cfd|_d|_d|_td|_d|_d|_d|_td|_ d|_ d|_ d|_ d|_ tjt d |_t d |_d|_d|_d|_d|_y) NrFrbutt)rNroundsolid)rrrrz hatch.colorzhatch.linewidth)_alpha _forced_alpha _antialiasedr _capstyle _cliprect _clippath_dashesr _joinstyle _linestyle _linewidth_rgb_hatchr to_rgbar _hatch_color_hatch_linewidth_url_gid_snap_sketchrs r4rCzGraphicsContextBase.__init__s "!&) #G,!(  "NN8M+BC (): ;    r6ch|j|_|j|_|j|_|j|_|j|_|j |_|j |_|j|_|j|_|j|_ |j|_ |j|_ |j|_ |j|_ |j|_|j|_|j |_|j"|_y)z"Copy properties from *gc* to self.N)r,r-r.r/r0r1r2r3r4r5r6r7r9r:r;r<r=r>)rIrWs r4rz#GraphicsContextBase.copy_propertiessii --OOzz ------GG ii OO " 3 3GG GG XX zz r6cy)z Restore the graphics context from the stack - needed only for backends that save graphics contexts on a stack. NrLrs r4rzGraphicsContextBase.restorerPr6c|jS)zc Return the alpha value used for blending - not supported on all backends. )r,rs r4 get_alphazGraphicsContextBase.get_alphas {{r6c|jS)zAReturn whether the object should try to do antialiased rendering.)r.rs r4get_antialiasedz#GraphicsContextBase.get_antialiased   r6c.|jjS)zReturn the `.CapStyle`.)r/namers r4 get_capstylez GraphicsContextBase.get_capstyles~~"""r6c|jS)zX Return the clip rectangle as a `~matplotlib.transforms.Bbox` instance. r0rs r4get_clip_rectanglez&GraphicsContextBase.get_clip_rectangles~~r6c|ji|jj\}}tjtj|j r||fSt jdyy)z Return the clip path in the form (path, transform), where path is a `~.path.Path` instance, and transform is an affine transform to apply to the path before clipping. z/Ill-defined clip_path detected. Returning None.NN)r1get_transformed_path_and_affinerallrre_logwarning)rItpathtrs r4 get_clip_pathz!GraphicsContextBase.get_clip_pathsZ >> %FFHIE2vvbkk%..12by  NO!r6c|jS)z Return the dash style as an (offset, dash-list) pair. See `.set_dashes` for details. Default value is (None, None). )r2rs r4 get_dasheszGraphicsContextBase.get_dashess||r6c|jS)z Return whether the value given by get_alpha() should be used to override any other alpha-channel values. )r-rs r4get_forced_alphaz$GraphicsContextBase.get_forced_alphas !!!r6c.|jjS)zReturn the `.JoinStyle`.)r3rGrs r4 get_joinstylez!GraphicsContextBase.get_joinstyle s###r6c|jS)z Return the line width in points.)r5rs r4rz!GraphicsContextBase.get_linewidths r6c|jS)z0Return a tuple of three or four floats from 0-1.)r6rs r4rzGraphicsContextBase.get_rgb yyr6c|jS)z+Return a url if one is set, None otherwise.r;rs r4get_urlzGraphicsContextBase.get_urlr]r6c|jS)z;Return the object identifier if one is set, None otherwise.r<rs r4get_gidzGraphicsContextBase.get_gidr]r6c|jS)a Return the snap setting, which can be: * True: snap vertices to the nearest pixel center * False: leave vertices as-is * None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center r=rs r4get_snapzGraphicsContextBase.get_snap szzr6c||||_d|_nd|_d|_|j|jdy)aB Set the alpha value used for blending - not supported on all backends. If ``alpha=None`` (the default), the alpha components of the foreground and fill colors will be used to set their respective transparencies (where applicable); otherwise, ``alpha`` will override them. NTrF)isRGBA)r,r-rr6)rIalphas r4 set_alphazGraphicsContextBase.set_alpha+s?  DK!%D DK!&D  DIId3r6c6tt||_y)z>Set whether object should be drawn with antialiased rendering.N)intboolr.)rIbs r4rz#GraphicsContextBase.set_antialiased<s QLr6c$t||_y)z Set how to draw endpoints of lines. Parameters ---------- cs : `.CapStyle` or %(CapStyle)s N)rr/)rIcss r4 set_capstylez GraphicsContextBase.set_capstyleAs""r6c||_y)z,Set the clip rectangle to a `.Bbox` or None.NrJ)rI rectangles r4set_clip_rectanglez&GraphicsContextBase.set_clip_rectangleLs "r6c`tjtjdf|||_y)z2Set the clip path to a `.TransformedPath` or None.N)rX)r check_isinstancerTransformedPathr1)rIrXs r4 set_clip_pathz!GraphicsContextBase.set_clip_pathPs$ z994@tLr6c|gtj|}tj|dkr td|jr#tj|dkDs td||f|_y)a] Set the dash style for the gc. Parameters ---------- dash_offset : float Distance, in points, into the dash pattern at which to start the pattern. It is usually set to 0. dash_list : array-like or None The on-off sequence as points. None specifies a solid line. All values must otherwise be non-negative (:math:`\ge 0`). Notes ----- See p. 666 of the PostScript `Language Reference `_ for more info. Nrz0All values in the dash list must be non-negativez4At least one value in the dash list must be positive)rasarrayany ValueErrorsizer2)rI dash_offset dash_listdls r4rzGraphicsContextBase.set_dashesUsn(  I&Bvvb3h FHHwwrvvb3h/ JLL"I- r6c|jr|r|dd|jfz|_y|jr&tj||j|_y|r||_ytj||_y)a Set the foreground color. Parameters ---------- fg : :mpltype:`color` isRGBA : bool If *fg* is known to be an ``(r, g, b, a)`` tuple, *isRGBA* can be set to True to improve performance. Nr)r-r,r6r r8)rIfgrhs r4rz"GraphicsContextBase.set_foregroundss`   &2A$++/DI   r4;;7DI DIr*DIr6c$t||_y)z Set how to draw connections between line segments. Parameters ---------- js : `.JoinStyle` or %(JoinStyle)s N)rr3)rIjss r4 set_joinstylez!GraphicsContextBase.set_joinstyles$B-r6c$t||_y)zSet the linewidth in points.N)rr5)rIrs r4rz!GraphicsContextBase.set_linewidths (r6c||_y)z-Set the url for links in compatible backends.Nr_)rIrs r4rzGraphicsContextBase.set_urls  r6c||_y)z Set the id.Nrb)rIids r4set_gidzGraphicsContextBase.set_gids  r6c||_y)a  Set the snap setting which may be: * True: snap vertices to the nearest pixel center * False: leave vertices as-is * None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center Nre)rIsnaps r4set_snapzGraphicsContextBase.set_snaps  r6c||_y)z Set the hatch style (for fills).Nr7)rIhatchs r4 set_hatchzGraphicsContextBase.set_hatchs  r6c|jS)zGet the current hatch style.rrs r4 get_hatchzGraphicsContextBase.get_hatchs {{r6cT|j}|ytj||S)z'Return a `.Path` for the current hatch.N)rrr)rIdensityrs r4get_hatch_pathz"GraphicsContextBase.get_hatch_paths'  =zz%))r6c|jS)zGet the hatch color.r9rs r4get_hatch_colorz#GraphicsContextBase.get_hatch_colorrEr6c||_y)zSet the hatch color.Nr)rI hatch_colors r4set_hatch_colorz#GraphicsContextBase.set_hatch_colors 'r6c|jS)zGet the hatch linewidth.r:rs r4get_hatch_linewidthz'GraphicsContextBase.get_hatch_linewidths$$$r6c||_y)zSet the hatch linewidth.Nr)rIhatch_linewidths r4set_hatch_linewidthz'GraphicsContextBase.set_hatch_linewidths /r6c|jS)a Return the sketch parameters for the artist. Returns ------- tuple or `None` A 3-tuple with the following elements: * ``scale``: The amplitude of the wiggle perpendicular to the source line. * ``length``: The length of the wiggle along the line. * ``randomness``: The scale factor by which the length is shrunken or expanded. May return `None` if no sketch parameters were set. r>rs r4get_sketch_paramsz%GraphicsContextBase.get_sketch_paramss$||r6Nc<|d|_y||xsd|xsdf|_y)a Set the sketch parameters. Parameters ---------- scale : float, optional The amplitude of the wiggle perpendicular to the source line, in pixels. If scale is `None`, or not provided, no sketch filter will be provided. length : float, default: 128 The length of the wiggle along the line, in pixels. randomness : float, default: 16 The scale factor by which the length is shrunken or expanded. Ng`@g0@r)rIrlength randomnesss r4set_sketch_paramsz%GraphicsContextBase.set_sketch_paramss, MD 4):s; r6)F)g@)NNN)+r!r"r#r$rCrrrBrDrHrKrTrVrXrZrrr`rcrfrjrrinterpdrqrtrxrrrrrrrrrrrrrrrrrLr6r4r r sG("* !# "$ 4") &&# .<+(((# *!(%0(=r6r ceZdZdZddZdZejddddd Zd Z d Z d Z e d Z e jdZ e dZejdZdZdZdZdZdZy) TimerBasea5 A base class for providing timer events, useful for things animations. Backends need to implement a few specific methods in order to use their own timing mechanisms so that the timer events are integrated into their event loops. Subclasses must override the following methods: - ``_timer_start``: Backend-specific code for starting the timer. - ``_timer_stop``: Backend-specific code for stopping the timer. Subclasses may additionally override the following methods: - ``_timer_set_single_shot``: Code for setting the timer to single shot operating mode, if supported by the timer object. If not, the `Timer` class itself will store the flag and the ``_on_timer`` method should be overridden to support such behavior. - ``_timer_set_interval``: Code for setting the interval on the timer, if there is a method for doing so on the timer object. - ``_on_timer``: The internal function that any timer object should call, which will handle the task of running all callbacks that have been set. NcZ|gn|j|_|dn||_d|_y)a# Parameters ---------- interval : int, default: 1000ms The time between timer events in milliseconds. Will be stored as ``timer.interval``. callbacks : list[tuple[callable, tuple, dict]] List of (func, args, kwargs) tuples that will be called upon timer events. This list is accessible as ``timer.callbacks`` and can be manipulated directly, or the functions `~.TimerBase.add_callback` and `~.TimerBase.remove_callback` can be used. NiF)copy callbacksinterval single_shotrIrrs r4rCzTimerBase.__init__ s/ )0inn6F ( 0h  r6c$|jy)z1Need to stop timer and possibly disconnect timer.N _timer_stoprs r4__del__zTimerBase.__del__ r63.9rztimer.interval) alternativec6|||_|jy)z Start the timer object. Parameters ---------- interval : int, optional Timer interval in milliseconds; overrides a previously set interval if provided. N)r _timer_startrIrs r4startzTimerBase.start s  $DM r6c$|jy)zStop the timer.Nrrs r4stopzTimerBase.stop/rr6cyrrLrs r4rzTimerBase._timer_start3 r6cyrrLrs r4rzTimerBase._timer_stop6rr6c|jS)z/The time between timer events, in milliseconds.) _intervalrs r4rzTimerBase.interval9s~~r6c\tt|d}||_|jy)Nr)rrlr_timer_set_intervalrs r4rzTimerBase.interval>s' s8}a(!   "r6c|jS)z2Whether this timer should stop after a single run.)_singlers r4rzTimerBase.single_shotGs||r6c2||_|jyr)r_timer_set_single_shot)rIsss r4rzTimerBase.single_shotLs  ##%r6cB|jj|||f|S)z Register *func* to be called by timer when the event fires. Any additional arguments provided will be passed to *func*. This function returns *func*, which makes it possible to use it as a decorator. )rappend)rIfuncrrs r4 add_callbackzTimerBase.add_callbackQs" tT623 r6c|s|r6tjdd|jj|||fy|jDcgc]}|d }}||vr+|jj |j |yycc}w)a Remove *func* from list of callbacks. *args* and *kwargs* are optional and used to distinguish between copies of the same function registered to be called with different arguments. This behavior is deprecated. In the future, ``*args, **kwargs`` won't be considered anymore; to keep a specific callback removable by itself, pass it to `add_callback` as a `functools.partial` object. z3.1zIn a future version, Timer.remove_callback will not take *args, **kwargs anymore, but remove all callbacks where the callable matches; to keep a specific callback removable by itself, pass it to add_callback as a functools.partial object.messagerN)r warn_deprecatedrremovepopindex)rIrrrcfuncss r4remove_callbackzTimerBase.remove_callback\s 6   , - NN ! !4v"6 7#'>>2aQqT2E2u}""5;;t#453s Bcy)z0Used to set interval on underlying timer object.NrLrs r4rzTimerBase._timer_set_intervalsrPr6cy)z3Used to set single shot on underlying timer object.NrLrs r4rz TimerBase._timer_set_single_shotvrPr6c|jD]2\}}}||i|}|dk(s|jj|||f4t|jdk(r|jyy)z Runs all function that have been registered as callbacks. Functions can return False (or 0) if they should not be called any more. If there are no callbacks, the timer is automatically stopped. rN)rrr`r)rIrrrrets r4 _on_timerzTimerBase._on_timerysp #'.. < D$''C ax%%tT6&:; < t~~ ! # IIK $r6rMr)r!r"r#r$rCrr delete_parameterrrrrpropertyrsetterrrrrrrrLr6r4rrs2!$T5*:JK L   __##&& 6.?Br6rceZdZdZddZdZy)Eventa A Matplotlib event. The following attributes are defined and shown with their default values. Subclasses may define additional attributes. Attributes ---------- name : str The event name. canvas : `FigureCanvasBase` The backend-specific canvas instance generating the event. guiEvent The GUI event that triggered the Matplotlib event. Nc.||_||_||_yr)rGcanvasguiEvent)rIrGrrs r4rCzEvent.__init__s    r6cr|jjj|j|d|_y)z?Process this event on ``self.canvas``, then unset ``guiEvent``.N)rrprocessrGrrs r4_processzEvent._processs' %%dii6 r6r)r!r"r#r$rCrrLr6r4rrs ! r6rc"eZdZdZfdZxZS) DrawEventa An event triggered by a draw operation on the canvas. In most backends, callbacks subscribed to this event will be fired after the rendering is complete but before the screen is updated. Any extra artists drawn to the canvas's renderer will be reflected without an explicit call to ``blit``. .. warning:: Calling ``canvas.draw`` and ``canvas.blit`` in these callbacks may not be safe with all backends and may cause infinite recursion. A DrawEvent has a number of special attributes in addition to those defined by the parent `Event` class. Attributes ---------- renderer : `RendererBase` The renderer for the draw event. c4t|||||_yr)rBrCr)rIrGrrrJs r4rCzDrawEvent.__init__s v&  r6r!r"r#r$rCr%r&s@r4rrs*!!r6rc"eZdZdZfdZxZS) ResizeEventa3 An event triggered by a canvas resize. A ResizeEvent has a number of special attributes in addition to those defined by the parent `Event` class. Attributes ---------- width : int Width of the canvas in pixels. height : int Height of the canvas in pixels. c`t||||j\|_|_yr)rBrCrrr)rIrGrrJs r4rCzResizeEvent.__init__s) v&"("9"9"; DKr6rr&s@r4rrs <*@& DJ   sAA A)(A)r)r!r"r#r$_last_axes_refrCrr%r&s@r4rrs &N!t!4r6rc eZdZdZdZdZdZdZy) MouseButtonrr N)r!r"r#LEFTMIDDLERIGHTBACKFORWARDrLr6r4rrs D F E DGr6rc6eZdZdZ ddddfd ZdZxZS) MouseEventa A mouse event ('button_press_event', 'button_release_event', 'scroll_event', 'motion_notify_event'). A MouseEvent has a number of special attributes in addition to those defined by the parent `Event` and `LocationEvent` classes. Attributes ---------- button : None or `MouseButton` or {'up', 'down'} The button pressed. 'up' and 'down' are used for scroll events. Note that LEFT and RIGHT actually refer to the "primary" and "secondary" buttons, i.e. if the user inverts their left and right buttons ("left-handed setting") then the LEFT button will be the one physically on the right. If this is unset, *name* is "scroll_event", and *step* is nonzero, then this will be set to "up" or "down" depending on the sign of *step*. buttons : None or frozenset For 'motion_notify_event', the mouse buttons currently being pressed (a set of zero or more MouseButtons); for other events, None. .. note:: For 'motion_notify_event', this attribute is more accurate than the ``button`` (singular) attribute, which is obtained from the last 'button_press_event' or 'button_release_event' that occurred within the canvas (and thus 1. be wrong if the last change in mouse state occurred when the canvas did not have focus, and 2. cannot report when multiple buttons are pressed). This attribute is not set for 'button_press_event' and 'button_release_event' because GUI toolkits are inconsistent as to whether they report the button state *before* or *after* the press/release occurred. .. warning:: On macOS, the Tk backends only report a single button even if multiple buttons are pressed. key : None or str The key pressed when the mouse event triggered, e.g. 'shift'. See `KeyEvent`. .. warning:: This key is currently obtained from the last 'key_press_event' or 'key_release_event' that occurred within the canvas. Thus, if the last change of keyboard state occurred while the canvas did not have focus, this attribute will be wrong. On the other hand, the ``modifiers`` attribute should always be correct, but it can only report on modifier keys. step : float The number of scroll steps (positive for 'up', negative for 'down'). This applies only to 'scroll_event' and defaults to 0 otherwise. dblclick : bool Whether the event is a double-click. This applies only to 'button_press_event' and is False otherwise. In particular, it's not used in 'button_release_event'. Examples -------- :: def on_press(event): print('you pressed', event.button, event.xdata, event.ydata) cid = fig.canvas.mpl_connect('button_press_event', on_press) N)buttonsrc Ft |||||| | |tjj vr t|}|dk(r||dkDrd}n|dkrd}||_|dk(rt | | ng|_n| r tdd|_||_ ||_ ||_ y)N)rr scroll_eventrupdownmotion_notify_eventz5'buttons' is only supported for 'motion_notify_event') rBrCr __members__valuesbuttonrrr|keystepdblclick) rIrGrrgrhrrrrrrrrJs r4rCzMouseEvent.__init__hs  &!QY  H [,,335 5 (F > !fnax ( ($0CWLDL  KMMDL   r6c|jd|jd|jd|jd|jd|j d|j d|jS)Nz: xy=(, z ) xydata=(z ) button=z dblclick=z inaxes=)rGrgrhrrrrrrs r4__str__zMouseEvent.__str__si99+vvhb 4::,b M++j@++( )r6)NNrFN)r!r"r#r$rCrr%r&s@r4rrs'GR=A26!!6)r6rc&eZdZdZ dfd ZxZS) PickEventa A pick event. This event is fired when the user picks a location on the canvas sufficiently close to an artist that has been made pickable with `.Artist.set_picker`. A PickEvent has a number of special attributes in addition to those defined by the parent `Event` class. Attributes ---------- mouseevent : `MouseEvent` The mouse event that generated the pick. artist : `~matplotlib.artist.Artist` The picked artist. Note that artists are not pickable by default (see `.Artist.set_picker`). other Additional attributes may be present depending on the type of the picked object; e.g., a `.Line2D` pick may define different extra attributes than a `.PatchCollection` pick. Examples -------- Bind a function ``on_pick()`` to pick events, that prints the coordinates of the picked data point:: ax.plot(np.rand(100), 'o', picker=5) # 5 points tolerance def on_pick(event): line = event.artist xdata, ydata = line.get_data() ind = event.ind print(f'on pick line: {xdata[ind]:.3f}, {ydata[ind]:.3f}') cid = fig.canvas.mpl_connect('pick_event', on_pick) c | |j}t| |||||_||_|j j |yr)rrBrC mouseeventartist__dict__update)rIrGrr#r$rrrJs r4rCzPickEvent.__init__sE  !**H vx0$  V$r6rrr&s@r4r!r!s$N%%r6r!c$eZdZdZdfd ZxZS)KeyEventa A key event (key press, key release). A KeyEvent has a number of special attributes in addition to those defined by the parent `Event` and `LocationEvent` classes. Attributes ---------- key : None or str The key(s) pressed. Could be *None*, a single case sensitive Unicode character ("g", "G", "#", etc.), a special key ("control", "shift", "f1", "up", etc.) or a combination of the above (e.g., "ctrl+alt+g", "ctrl+alt+G"). Notes ----- Modifier keys will be prefixed to the pressed key and will be in the order "ctrl", "alt", "super". The exception to this rule is when the pressed key is itself a modifier key, therefore "ctrl+alt" and "alt+control" can both be valid key values. Examples -------- :: def on_key(event): print('you pressed', event.key, event.xdata, event.ydata) cid = fig.canvas.mpl_connect('key_press_event', on_key) c<t||||||||_yr)rBrCr)rIrGrrrgrhrrJs r4rCzKeyEvent.__init__s" vq!h?r6)rrNrr&s@r4r(r(s>r6r(c|jdk(r|j|j_y|jdk(rd|j_yy)Nkey_press_eventkey_release_event)rGrr_key)events r4 _key_handlerr/s= zz&&!II  * *   +r6c|jdk(r|j|j_nW|jdk(rd|j_n6|jdk(r'|j|jj|_|j|jj |_|jdk(rt j}|r|nd}||jk7r| |jdj}t d||j|j|j|j}|j||jj!d||j&|jjj!d||jrt%j&|jndt _yy#t"$rYuwxYw) Nbutton_press_eventbutton_release_eventrTrootaxes_leave_eventraxes_enter_event)rGrr_buttonrr-rrr get_figurergrhrrrrr Exceptionweakrefref)r.last_ref last_axesr leave_events r4_mouse_handlerr?s} zz))$||  - -#  , ,1E||++  yyLL%%  zz** //"*HJ  $$ &11t1<CCF"/*F%.."'//#3K ++I6$$,,-?M||' &&../A5I).GKK %4 $-+$!s'BG GGcGddtfd}tj||5t5}|D|jj }|j |jj|} |tjt|d#$r,}|j\}|cYd}~cdddcdddSd}~wwxYw#1swYnxYwdddy#1swYyxYw)z Get the renderer that would be used to save a `.Figure`. If you need a renderer without any active draw methods use renderer._draw_disabled to temporary patch them out at your call site. c eZdZy)_get_renderer..DoneN)r!r"r#rLr6r4DonerBs r6rCc|rrL)rrCs r4_drawz_get_renderer.._draws tH~-r6)drawNz6 did not call Figure.draw, so no renderer is available) r9r rrrget_default_filetype enter_context&_switch_canvas_and_return_print_methodioBytesIO RuntimeErrorr)figure print_methodrEstackfmtexcrrCs @r4 _get_rendererrRs y .   6 .<  B ! >$& > :t4=?r6c#bKtjtj}|dtjtjfvrdydt j \}}|jd|jdtj|j}||fd}tjtj| d|j|jtj|tjtj||yy#|j|jtj|tjtj||wwxYww)a A context manager that allows terminating a plot by sending a SIGINT. It is necessary because the running backend prevents the Python interpreter from running and processing signals (i.e., to raise a KeyboardInterrupt). To solve this, one needs to somehow wake up the interpreter and make it close the plot window. We do this by using the signal.set_wakeup_fd() function which organizes a write of the signal number into a socketpair. A backend-specific function, *prepare_notifier*, arranges to listen to the pair's read socket while the event loop is running. (If it returns a notifier object, that object is kept alive while the context manager runs.) If SIGINT was indeed caught, after exiting the on_signal() function the interpreter reacts to the signal according to the handler function which had been set up by a signal.signal() call; here, we arrange to call the backend-specific *handle_sigint* function, passing the notifier object as returned by prepare_notifier(). Finally, we call the old SIGINT handler with the same arguments that were given to our custom handler. We do this only if the old handler for SIGINT was not None, which means that a non-python handler was installed, i.e. in Julia, and not SIG_IGN which means we should ignore the interrupts. Parameters ---------- prepare_notifier : Callable[[socket.socket], object] handle_sigint : Callable[[object], object] NFc|dyrrL)r handle_sigint handler_argsnotifiers r4save_args_and_handle_sigintz5_allow_interrupt..save_args_and_handle_sigintms hr6) signal getsignalSIGINTSIG_IGNSIG_DFLsocket socketpair setblocking set_wakeup_fdfilenoclose) prepare_notifierr_old_sigint_handlerwsockrsock old_wakeup_fdrbr`ras ` @@r4_allow_interruptrsCs?< ))&--8dFNNFNNCC L$$&LE5 e e((8M&H  MM&--!<=.   ]+ fmm%78  #  - $   ]+ fmm%78  #  - $s CF/#E 'A"F/ A#F,,F/ceZdZdZdZej dZgdZdZ e Z ej dZ d'fd Z edZedZed Zeej(d Zed Zed Zd Zd'dZdZdZdZdZdZdZ edZ!dZ"dddZ#edZ$edZ%ed'dZ& d(ddddddZ'edZ(d Z)d!Z*d"Z+e,Z-d)d#Z.d$Z/d*d%Z0d&Z1xZ2S)+FigureCanvasBasez The canvas the figure renders into. Attributes ---------- figure : `~matplotlib.figure.Figure` A high-level figure instance. NctSr)FigureManagerBaseclss r4rzFigureCanvasBase.s3Dr6) resize_event draw_eventr+r,r1r2rr pick_eventfigure_enter_eventfigure_leave_eventr6r5 close_eventc6t|dxr t|dS)z+If this Canvas sub-class supports blitting.copy_from_bboxrestore_region)rYrxs r4 supports_blitzFigureCanvasBase.supports_blits$-.3C!12 4r6cbddlm}|jd|_d|_||}|j |||_d|_tj|_ d|_ d|_ d|_ d|_d|_|j|_d|_t$|My)NrFigureTFr)matplotlib.figurer_fix_ipython_backend2gui_is_idle_drawing _is_saving set_canvasrMmanagerrLockDraw widgetlockr7r-rtoolbarr _original_dpi_device_pixel_ratiorBrC)rIrMrrJs r4rCzFigureCanvasBase.__init__s, %%' $ >XF$  !**,  ! %%zz#$  r6c.|jjSr)rM_canvas_callbacksrs r4rzFigureCanvasBase.sdkk&C&Cr6c.|jjSr)rM_button_pick_idrs r4rzFigureCanvasBase.4;;+F+Fr6c.|jjSr)rM_scroll_pick_idrs r4rzFigureCanvasBase.rr6cZtjjd}||jdddk\ryddl}|j }|syddlm}t|dr t|dsydd d d d d j|j}|rt|r|j|yyy)NIPythonr)rr) pylabtools backend2guienable_matplotlibqtgtk3gtk4wxosx)rrrrmacosx) sysmodulesget version_infor get_ipython IPython.corerrYrequired_interactive_frameworkr\ enable_gui)ry mod_ipythonrr[ptbackend2gui_rifs r4rz)FigureCanvasBase._fix_ipython_backend2guiskkooi0  +":":2A">'"I   " 1M*r#67   #c00 1  3B7 o.8 r6c<|jj|||S)a& Create a new figure manager for *figure*, using this canvas class. Notes ----- This method should not be reimplemented in subclasses. If custom manager creation logic is needed, please reimplement ``FigureManager.create_with_canvas``. ) manager_classcreate_with_canvas)ryrMnums r4 new_managerzFigureCanvasBase.new_managers  33CEEr6c#JKd|_ dd|_y#d|_wxYww)NTF)rrs r4_idle_draw_cntxz FigureCanvasBase._idle_draw_cntxs& $ * $)D !ED !s## #c|jS)z Return whether the renderer is in the process of saving to a file, rather than rendering for an on-screen buffer. rrs r4 is_savingzFigureCanvasBase.is_savings r6cy)z0Blit the canvas in bbox (default entire canvas).NrL)rIbboxs r4blitzFigureCanvasBase.blit rPr6c|jjDcgc]/}|jj|r|j r|1}}|rt j |}|Sd}|Scc}w)a Return the topmost visible `~.axes.Axes` containing the point *xy*. Parameters ---------- xy : (float, float) (x, y) pixel positions from left/bottom of the canvas. Returns ------- `~matplotlib.axes.Axes` or None The topmost visible Axes containing the point, or None if there is no Axes at the point. N)rMget_axespatchcontains_point get_visibler _topmost_artist)rIra axes_listaxess r4rzFigureCanvasBase.inaxes sv!% 4 4 6H1..r2q}}H H ((3D D Hs4A0cH|jd|fvr td||_y)z Set the child `~.axes.Axes` which is grabbing the mouse events. Usually called by the widgets themselves. It is an error to call this if the mouse is already grabbed by another Axes. Nz&Another Axes already grabs mouse input)rrLrIaxs r4 grab_mousezFigureCanvasBase.grab_mouse%s*   dBZ /GH Hr6c0|j|urd|_yy)z Release the mouse grab held by the `~.axes.Axes` *ax*. Usually called by the widgets. It is ok to call this even if *ax* doesn't have the mouse grab currently. N)rrs r4 release_mousezFigureCanvasBase.release_mouse0s    #!%D  $r6cy)a. Set the current cursor. This may have no effect if the backend does not display anything. If required by the backend, this method should trigger an update in the backend event loop after the cursor is set, as this method may be called e.g. before a long-running task during which the GUI is not updated. Parameters ---------- cursor : `.Cursors` The cursor to display over the canvas. Note: some backends may change the cursor for the entire window. NrL)rIcursors r4 set_cursorzFigureCanvasBase.set_cursor:rPr6cy)a( Render the `.Figure`. This method must walk the artist tree, even if no output is produced, because it triggers deferred work that users may want to access before saving output to disk. For example computing limits, auto-limits, and tick values. NrLrIrrs r4rFzFigureCanvasBase.drawLrPr6c|js,|j5|j|i|dddyy#1swYyxYw)a Request a widget redraw once control returns to the GUI event loop. Even if multiple calls to `draw_idle` occur before control returns to the GUI event loop, the figure will only be rendered once. Notes ----- Backends may choose to override the method and implement their own strategy to prevent multiple renderings. N)rrrFrs r4 draw_idlezFigureCanvasBase.draw_idleVsK$$%%' + 4*6* + +% + +s :Ac|jS)a The ratio of physical to logical pixels used for the canvas on screen. By default, this is 1, meaning physical and logical pixels are the same size. Subclasses that support High DPI screens may set this property to indicate that said ratio is different. All Matplotlib interaction, unless working directly with the canvas, remains in logical pixels. rrs r4device_pixel_ratioz#FigureCanvasBase.device_pixel_ratiogs'''r6c|j|k(ry||jjz}|jj|d||_y)a Set the ratio of physical to logical pixels used for the canvas. Subclasses that support High DPI screens can set this property to indicate that said ratio is different. The canvas itself will be created at the physical size, while the client side will use the logical size. Thus the DPI of the Figure will change to be scaled by this ratio. Implementations that support High DPI screens should use physical pixels for events so that transforms back to Axes space are correct. By default, this is 1, meaning physical and logical pixels are the same size. Parameters ---------- ratio : float The ratio of logical to physical pixels used for the canvas. Returns ------- bool Whether the ratio has changed. Backends may interpret this as a signal to resize the window, repaint the canvas, or change any other relevant properties. F)forwardT)rrMr_set_dpi)rIratiors r4_set_device_pixel_ratioz(FigureCanvasBase._set_device_pixel_ratiotsM6  # #u , dkk/// S%0#( r6F)physicalcltfdjjjDS)a Return the figure width and height in integral points or pixels. When the figure is used on High DPI screens (and the backend supports it), the truncation to integers occurs after scaling by the device pixel ratio. Parameters ---------- physical : bool, default: False Whether to return true physical pixels or logical pixels. Physical pixels may be used by backends that support HiDPI, but still configure the canvas using its actual size. Returns ------- width, height : int The size of the figure, in points or pixels, depending on the backend. c3VK|] }t|rdn jz "yw)rN)rlr).0r}rrIs r4 z4FigureCanvasBase.get_width_height..s-7hD4K4KLM7s&))tuplerMrr)rIrs``r4rz!FigureCanvasBase.get_width_heights/*7!%!1!1!5!577 7r6c|jS)z>Return dict of savefig file formats supported by this backend.) filetypesrxs r4get_supported_filetypesz(FigureCanvasBase.get_supported_filetypess}}r6ci}|jjD]9\}}|j|gj|||j ;|S)a Return a dict of savefig file formats supported by this backend, where the keys are a file type name, such as 'Joint Photographic Experts Group', and the values are a list of filename extensions used for that filetype, such as ['jpg', 'jpeg']. )ritems setdefaultrsort)ry groupingsextrGs r4get_supported_filetypes_groupedz0FigureCanvasBase.get_supported_filetypes_groupeds\ ,,. #IC  r * 1 1# 6 dO " #r6c #P Kd}|Uddlm}|j|j}t |d|st d|d|d||j }nrt |d|r|}n`t|}|At dj|d jt|j||j }|j|_ t|d| t d r jjn j}|j!d rHhd }|ht#j$ j&z t)j*  fd }n } |||j _y#||j _wxYww)a Context manager temporarily setting the canvas for saving the figure:: with (canvas._switch_canvas_and_return_print_method(fmt, backend) as print_method): # ``print_method`` is a suitable ``print_{fmt}`` method, and # the figure's canvas is temporarily switched to the method's # canvas within the with... block. ``print_method`` is also # wrapped to suppress extra kwargs passed by ``print_figure``. Parameters ---------- fmt : str If *backend* is None, then determine a suitable canvas class for saving to format *fmt* -- either the current canvas class, if it supports *fmt*, or whatever `get_registered_canvas_class` returns; switch the figure canvas to that canvas class. backend : str or None, default: None If not None, switch the figure canvas to the ``FigureCanvas`` class of the given backend. Nr)backend_registryprint_zThe z backend does not support z outputz4Format {!r} is not supported (supported formats: {})rr)z matplotlib.z mpl_toolkits.>r edgecolor facecolor orientationbbox_inches_restorec n|i|jDcic] \}}|vs ||c}}Scc}}wr)r)rrkvmethskips r4rzIFigureCanvasBase._switch_canvas_and_return_print_method..s=JM+1<<>K41aQd]!Q$KJMKs 11)backends.registryrload_backend_moduler<rYr|rMr>r1joinsortedrrrZrr"rinspect signature parameters functoolswrapsr) rIrPr2rr canvas_classmod optional_kwsrNrrs @@r4rIz7FigureCanvasBase._switch_canvas_and_return_print_methods.   ;+??HUUL<6#8 7+%?uGLNN!$++.F TVC5> *F7s;L# JQQTYYvd.J.J.L'MNPQQ"$++.F OOvu~.$'yy##OO  >>: ;'L "GG$5$5d$;$F$F"GGD09??402MNL L & !%DKK DKK sE5F&:F>F&F##F&) bbox_inches pad_inchesbbox_extra_artistsr2c P |t|tjrtj|}t|tr%tj j |ddd}||dk(r7|j}t|tr|jddz|z}|j}| td}|dk(r+t|jd|jj}tj|d5|j!|| 5} tj|j| 5tj|jj"d 5tj|jj"d 5t%5} d D]a}t'|}| td|}tj(|dr5| j+|jj,di||ic| td}|jj/}||dk(ret1|jt3j4| |}t|dt65|jj9|ddd|r|dk(r||jj;| }t|t<r,|dk(r'|j?d}|j?d}n|dvr td}|x}}|jA||}tCjD|j||jj"jF}||f}nd}| j+|jj-d tj|j| 5| |f||||d| }ddd|r r| cdddcdddcdddcdddcdddcdddS#1swY{xYw#1swYZxYw#|r r|wwwxYw#1swYnxYwdddn #1swYnxYwdddn #1swYnxYwdddn #1swYnxYwdddn #1swYnxYwdddy#1swYyxYw)as Render the figure to hardcopy. Set the figure patch face and edge colors. This is useful because some of the GUIs have a gray figure face color background and you'll probably want to override this on hardcopy. Parameters ---------- filename : str or path-like or file-like The file where the figure is saved. dpi : float, default: :rc:`savefig.dpi` The dots per inch to save the figure in. 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. orientation : {'landscape', 'portrait'}, default: 'portrait' Only currently applies to PostScript printing. format : str, optional Force a specific file format. If not given, the format is inferred from the *filename* extension, and if that fails from :rc:`savefig.format`. bbox_inches : 'tight' 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. bbox_extra_artists : list of `~matplotlib.artist.Artist`, optional A list of extra artists that will be considered when the tight bbox is calculated. 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://...". Nrr..z savefig.dpirMr)r)rrTr)rrzsavefig.autoz savefig.bboxtight)rr )rlayouth_padw_pad)Nr zsavefig.pad_inchesnone) layout_engine)rrrrrL)$r8osPathLikefspathr9rXsplitextrGrstriplowerrrZrMrr rrIrrlocals _str_equalrH_cm_setget_layout_enginerRrpartialrrF get_tightbboxrrpaddedr adjust_bbox fixed_dpi)rIfilenamerrrrr1rrrr2rrNrOrrrrr r  restore_bbox_bbox_inches_restoreresults r4 print_figurezFigureCanvasBase.print_figuresmr >(BKK099X.(C())(3A6qr:~2224h,'s3c9FBH ;=)C (?$++ HCd3G 99&'JG   5G  2 2J G   2 2tD G  k G  #2 N=$xv%67E''v6''(; (;(;(LtUm(LM  N"&~6  KK99;M(K7,B)KK%%$+?FWX'7EG/KK$$X./')"&++";"; 5G#<#IK"=2IJ&(2 - 1 1 3G < - 1 1 3G <%)99)12F)GJ(22"-"4"4UE"BK +66KKdkk.@.@.J.J L )4\'B$'+$    3 3& 3 I J #&&t{{<") ""+"+$/,@ " ! "F"< NOG G G G G G G <//:""< N$0;IG G G G G G G G G G G G G G G G G sR"R<,Q2(,Q  Q 7P3 BP3 3PC RR RR%ctdS)z Return the default savefig file format as specified in :rc:`savefig.format`. The returned string does not include a period. This method is overridden in backends that only support a single file type. zsavefig.format)rrxs r4rGz%FigureCanvasBase.get_default_filetypes())r6c|j|jjnd}|xsd}d}|j|Dcic]}t|dc}}|j }|d|Scc}w)zN Return a suitable default filename, including the extension. r.imagez <>:"/\|?* _r)rget_window_titleraordrG)rIdefault_basename removed_charsrdefault_filetypes r4get_default_filenamez%FigureCanvasBase.get_default_filenames ||' LL ) ) +  ,6w( +55"/ 0QSVS[ 02446"#1%5$677 1sA1c:|jj||S)a Bind function *func* to event *s*. Parameters ---------- s : str One of the following events ids: - 'button_press_event' - 'button_release_event' - 'draw_event' - 'key_press_event' - 'key_release_event' - 'motion_notify_event' - 'pick_event' - 'resize_event' - 'scroll_event' - 'figure_enter_event', - 'figure_leave_event', - 'axes_enter_event', - 'axes_leave_event' - 'close_event'. func : callable The callback function to be executed, which must have the signature:: def func(event: Event) -> Any For the location events (button and key press/release), if the mouse is over the Axes, the ``inaxes`` attribute of the event will be set to the `~matplotlib.axes.Axes` the event occurs is over, and additionally, the variables ``xdata`` and ``ydata`` attributes will be set to the mouse location in data coordinates. See `.KeyEvent` and `.MouseEvent` for more info. .. note:: If func is a method, this only stores a weak reference to the method. Thus, the figure does not influence the lifetime of the associated object. Usually, you want to make sure that the object is kept alive throughout the lifetime of the figure by holding a reference to it. Returns ------- cid A connection id that can be used with `.FigureCanvasBase.mpl_disconnect`. Examples -------- :: def on_press(event): print('you pressed', event.button, event.xdata, event.ydata) cid = canvas.mpl_connect('button_press_event', on_press) )rconnect)rIrMrs r4 mpl_connectzFigureCanvasBase.mpl_connectsz~~%%a..r6c:|jj|y)z Disconnect the callback with id *cid*. Examples -------- :: cid = canvas.mpl_connect('button_press_event', on_press) # ... later canvas.mpl_disconnect(cid) N)r disconnect)rIcids r4mpl_disconnectzFigureCanvasBase.mpl_disconnects !!#&r6c(|j||S)a Create a new backend-specific subclass of `.Timer`. This is useful for getting periodic events through the backend's native event loop. Implemented only for backends with GUIs. Parameters ---------- interval : int Timer interval in milliseconds. callbacks : list[tuple[callable, tuple, dict]] Sequence of (func, args, kwargs) where ``func(*args, **kwargs)`` will be executed by the timer every *interval*. Callbacks which return ``False`` or ``0`` will be removed from the timer. Examples -------- >>> timer = fig.canvas.new_timer(callbacks=[(f1, (1,), {'a': 3})]) )rr) _timer_clsrs r4 new_timerzFigureCanvasBase.new_timer s.IFFr6cy)zu Flush the GUI events for the figure. Interactive backends need to reimplement this method. NrLrs r4 flush_eventszFigureCanvasBase.flush_events rPr6c|dkrtj}d}d}d|_|jrJ||z|krA|jt j ||dz }|jr ||z|kr?yyyy)aK Start a blocking event loop. Such an event loop is used by interactive functions, such as `~.Figure.ginput` and `~.Figure.waitforbuttonpress`, to wait for events. The event loop blocks until a callback function triggers `stop_event_loop`, or *timeout* is reached. If *timeout* is 0 or negative, never timeout. Only interactive backends need to reimplement this method and it relies on `flush_events` being properly implemented. Interactive backends should implement this in a more native way. rg{Gz?TrN)rinf_loopingr8timesleep)rItimeouttimestepcounters r4start_event_loopz!FigureCanvasBase.start_event_loop& su$ a<ffG mm( 2W <     JJx qLGmm( 2W jAtC| |j;dYd} ~ Cd} ~ wwxYw#t6$r9} t>jAtC| |jGdYd} ~ d} ~ wwxYw)a Implement the default Matplotlib key bindings for the canvas and toolbar described at :ref:`key-event-handling`. Parameters ---------- event : `KeyEvent` A key press/release event. canvas : `FigureCanvasBase`, default: ``event.canvas`` The backend-specific canvas instance. This parameter is kept for back-compatibility, but, if set, should always be equal to ``event.canvas``. toolbar : `NavigationToolbar2`, default: ``event.canvas.toolbar`` The navigation cursor toolbar. This parameter is kept for back-compatibility, but, if set, should always be equal to ``event.canvas.toolbar``. Nzkeymap.fullscreenz keymap.quitzkeymap.quit_allz keymap.home keymap.backkeymap.forwardz keymap.panz keymap.zoomz keymap.savecVtd|DrdStd|DsdSdS)Nc3PK|]}|jj ywrgridlinerrticks r4rzDkey_press_handler.._get_uniform_gridstate.. sJDDMM557J$&Tc3PK|]}|jj ywrrPrRs r4rzDkey_press_handler.._get_uniform_gridstate.. s O!:!:!< OrTF)rOr{)tickss r4_get_uniform_gridstatez1key_press_handler.._get_uniform_gridstate s6JEJJ  O OO  r6z keymap.grid))FF)TF)TT)FTrmajorbothrg)whichaxisrhzkeymap.grid_minorz keymap.yscaleloglinearTr3z keymap.xscale)$rrrrrfull_screen_toggleAttributeErrorr destroy_figrM destroy_allhomebackrpan_update_cursorzoom save_figurerxaxis minorTicksyaxis majorTicksrr`gridrr| get_yscale set_yscaler8rPrQr9 get_xscale set_xscale) r.rrrWrx_statey_staterrrQscalexs r4key_press_handlerrtL s$ yy ~.. yyH011  NN - - /  yyH]++  & yyH.//  99/ / LLNYY(=1 1 LLN YY(#34 4 OO  YY(<0 0 KKM  " "5 ) YY(=1 1 LLN  " "5 ) YY(=1 1    ! || B  Xm,,3BHH4G4GH3BHH4G4GHJJ()<)<=()<)<=L u{{GW#56:c%jHI GW GGGg76G L GGGg76G L     X1223BHH4G4GH3BHH4G4GHJJ()<)<=()<)<=L u{{GW#56:c%jHI GW GGG6G 4 GGG6G 4     h/ /  E> MM( # MMtM $ + + 5 5 7 h  ( e$ MMtM $ + + 5 5 7  h/ / U? MM( # MMtM $ + + 5 5 7 x  ( e$ MMtM $ + + 5 5 7  0E   t   &     ( SX& h'' ( ( SX& h'' (sfT'(T(T/(T>V TT T,+T,/ T;:T;> V/U<<V W /WWc| |j}| |j}|Wtt|j}|t dvr|j y|t dvr|jyyy)z The default Matplotlib button actions for extra mouse buttons. Parameters are as for `key_press_handler`, except that *event* is a `MouseEvent`. NrLrM)rrr9rrrrcr)r.rr button_names r4button_press_handlerrw sq~..+ell34 (=1 1 LLN H%56 6 OO 7 r6ceZdZdZy)NonGuiExceptionz6Raised when trying show a figure in a non-GUI backend.NrrLr6r4ryry s@r6rycxeZdZdZdZdZdZedZedZ edddZ dZ d Z d Z d Zd Zd Zy)rwa A backend-independent abstraction of a figure container and controller. The figure manager is used by pyplot to interact with the window in a backend-independent way. It's an adapter for the real (GUI) framework that represents the visual figure on screen. The figure manager is connected to a specific canvas instance, which in turn is connected to a specific figure instance. To access a figure manager for a given figure in user code, you typically use ``fig.canvas.manager``. GUI backends derive from this class to translate common operations such as *show* or *resize* to the GUI-specific code. Non-GUI backends do not support these operations and can just use the base class. This following basic operations are accessible: **Window operations** - `~.FigureManagerBase.show` - `~.FigureManagerBase.destroy` - `~.FigureManagerBase.full_screen_toggle` - `~.FigureManagerBase.resize` - `~.FigureManagerBase.get_window_title` - `~.FigureManagerBase.set_window_title` **Key and mouse button press handling** The figure manager sets up default key and mouse button press handling by hooking up the `.key_press_handler` to the matplotlib event system. This ensures the same shortcuts and mouse actions across backends. **Other operations** Subclasses will have additional attributes and functions to access additional functionality. This is of course backend-specific. For example, most GUI backends have ``window`` and ``toolbar`` attributes that give access to the native GUI widgets of the respective framework. Attributes ---------- canvas : `FigureCanvasBase` The backend-specific canvas instance. num : int or str The figure number. key_press_handler_id : int The default key handler cid, when using the toolmanager. To disable the default key press handling use:: figure.canvas.mpl_disconnect( figure.canvas.manager.key_press_handler_id) button_press_handler_id : int The default mouse button handler cid, when using the toolmanager. To disable the default button press handling use:: figure.canvas.mpl_disconnect( figure.canvas.manager.button_press_handler_id) Nc|_|_|_jd|dd_d_t ddk7rJjjdt_jjdt_tj ddk(rt|jnd_ tj ddk(r-jr!jj_nJtj ddk(r-j r!j!j_nd_jrJt#j$jjrt#j&jjjj(fd}y) NzFigure rr toolmanagerr+r1toolbar2cnj(jjjyyyr)r|rr&)figrIs r4notify_axes_changez6FigureManagerBase.__init__..notify_axes_changeR s3'DLL,D ##%-E'r6)rrrset_window_titlekey_press_handler_idbutton_press_handler_idrr/rtrwmplrrMr|_toolbar2_classr_toolmanager_toolbar_classtoolsadd_tools_to_manageradd_tools_to_containeradd_axobserver)rIrrrs` r4rCzFigureManagerBase.__init__3 su  Aw/0$(!'+$ I - /(, (?(?!#4)6D %+/;;+B+B$&:,n.>*>E     ! # -""3s8,, -sB  B=B88B=ctjdk(r tjj dsyt t |jjd)a For GUI backends, show the figure window and redraw. For non-GUI backends, raise an exception, unless running headless (i.e. on Linux with an unset DISPLAY); this exception is converted to a warning in `.Figure.show`. linuxDISPLAYNz- is non-interactive, and thus cannot be shown) rplatformrenvironrrytyperr!rs r4rzFigureManagerBase.show sP <<7 "2::>>)+D DKK ))*+  r6cyrrLrs r4destroyzFigureManagerBase.destroy rr6cyrrLrs r4r^z$FigureManagerBase.full_screen_toggle rr6cy)z9For GUI backends, resize the window (in physical pixels).NrL)rIrrs r4resizezFigureManagerBase.resize rPr6c|jS)z:Return the title text of the window containing the figure. _window_titlers r4r'z"FigureManagerBase.get_window_title s!!!r6c||_y)z Set the title text of the window containing the figure. Examples -------- >>> fig = plt.figure() >>> fig.canvas.manager.set_window_title('My figure') Nr)rItitles r4rz"FigureManagerBase.set_window_title s #r6)r!r"r#r$rrrCrIrrrrrr^rr'rrLr6r4rwrw sz<|O!%#&J..    "& " "D$  H"#r6rwc.eZdZdZdZdZdZedZy)_Moder.zpan/zoomz zoom rectc|jSr)valuers r4rz _Mode.__str__ s zzr6cB|tjur |jSdSr)rNONErGrs r4_navigate_modez_Mode._navigate_mode s  2tyy<)  %--"7"7 7 KK " "5==#8#8 9 % 5 5D 8r6c#Ktjt|dtj c|_}|j|z dkDr^ |j j tjjd|j j |jydy#|j j |jwxYww)a Set the cursor to a wait cursor when drawing the canvas. In order to avoid constantly changing the cursor when the canvas changes frequently, do nothing if this context was triggered during the last second. (Optimally we'd prefer only setting the wait cursor if the *current* draw takes too long, but the current draw blocks the GUI thread). _draw_timerN) r<rZrr:rrrrrWAITr)rIlast_draw_times r4_wait_cursor_for_draw_cmz+NavigationToolbar2._wait_cursor_for_draw_cm^ s IIK|bffW= ( ??^ +a / : &&u}}'9'9: &&t'8'89  &&t'8'89sA C 7B.+C.'CCcp|jr|jjr |jj|j|j}|j }|jj Dcgc](}|j|dr|jr|*}}|ritj|}||jjur<|j|}|)|j|j }|r|dz|z}|Sycc}w#ttf$rYywxYw)Nr r.)rr format_coordrrr_mouseover_setcontainsrr rrget_cursor_dataformat_cursor_datar| OverflowError)r.rMrartistsdatadata_strs r4_mouse_event_to_messagez*NavigationToolbar2._mouse_event_to_messaget s <._ax_filter s=JJu%3OO%30GB$vh02 r6ch|j}|dk(r|jj }| S)Nr)get_forward_navigation_eventsrr)rfs r4_capture_eventszINavigationToolbar2._start_event_axes_interaction.._capture_events s3002AF{,,..5Lr6rT)reverse)rmfilterrrMrr`r push_currentdictreversedr get_zorderrrextend _twinned_axes get_siblingsfromkeys) rIr.rrrrgrpsraxes_to_triggerzorders `` r4_start_event_axes_interactionz0NavigationToolbar2._start_event_axes_interaction s$   F:t{{'9'9'B'B'DEF t9>I ??  $    v4. r6c|jjj|s|jdy|jt j k(r;t j|_|jjj|n0t j |_|jj||jjjD]'}|j|jj)y)z[ Toggle the pan/zoom tool. Pan with left button, zoom with right. zpan unavailableN) rr availablerrrrrreleaserMrset_navigate_moderrIrrs r4rdzNavigationToolbar2.pan s {{%%//5   . /  99 ! DI KK " " * *4 0 DI KK " "4 (##,,. :A   8 8 9 :r6_PanInfozbutton axes cidc|jtjtjfvs|j |j y|j |d}|sy|D]3}|j|j|j |j5|jj|j|jjd|j}|j|j|||_y)z1Callback for mouse button press in pan/zoom mode.Nrdrr)rrr2)rrr r rgrhr start_panrr3rr/drag_panrr)rIr.rrid_drags r4rzNavigationToolbar2.press_pan s LL!1!1;3D3D E E77?eggo 11%1F  9B LL%''5<< 8 9 ""4==1++))*?O<> !  ""4>>#5#56 // !4??4 ..%% B JJL   r6c |jjj|s|jdy |jt j k(r;t j|_|jjj|n0t j |_|jj||jjjD]'}|j|jj)y)Nzzoom unavailable) rrrrrrrrrrMrrrrs r4rfzNavigationToolbar2.zoom s{{%%//5   / 0 ' 99 " DI KK " " * *4 0 DI KK " "4 (##,,. :A   8 8 9 :r6 _ZoomInfoz direction start_xy axes cid cbarc|jtjtjfvs|j |j y|j |d}|sy|jjd|j}|d}t|dr|jj}nd}|j|jdk(rdnd |j|j f||| |_y) z5Callback for mouse button press in zoom to rect mode.Nrfrrr _colorbarrinout) directionstart_xyrr2cbar)rrr r rgrhrrr/ drag_zoomrYr'rr%r)rIr.rid_zoom parent_axr,s r4rzNavigationToolbar2.press_zoom s LL!1!1;3D3D E E77?eggo 11%1G ++)) !4>>3 G 9k *&&22DD..#lla/dUgguww'dd)Lr6cL|jj}|jjd}tj||j |j gg|jj|jj\\}}\}}|j}|jjdk(rd}n|jjdk(rd}|dk(r|jj\}}n|dk(r|jj\}}|j|||||y)z#Callback for dragging in zoom mode.r horizontalrgverticalrhN)rr+rrcliprgrhrminrrr, intervaly intervalxr) rIr.r+rrrx2y2rs r4r-zNavigationToolbar2.drag_zoom6 s??++ __ ! !! $WW ) *BGGKKFR(2rii ??  < /C __ ! !Z /C #:WW&&FB CZWW&&FB UBB3r6c|jy|jj|jj|j |jj \}}|j }|jjdk(rd}n|jjdk(rd}t|j|z dkr|dk7s t|j|z dkr'|dk7r"|jjd|_yt|jjD]\}tfd|jjd|D}tfd|jjd|D}j|||j|jf|jj ||||jjd|_|j#y) z7Callback for mouse button release in zoom to rect mode.Nr1rgr2rhc3^K|]$}jj|&ywr)get_shared_x_axesjoinedrprevrs r4rz2NavigationToolbar2.release_zoom..f /> ,,.55b$?>*-c3^K|]$}jj|&ywr)get_shared_y_axesr=r>s r4rz2NavigationToolbar2.release_zoom..h r@rA)rrr3r2rr+rr,absrgrhr enumeraterr{_set_view_from_bboxr*r ) rIr.start_xstart_yrrtwinxtwinyrs @r4rzNavigationToolbar2.release_zoomI s ?? "  ""4??#6#67  ??33ii ??  < /C __ ! !Z /C7" #a 'C3JUWWw&'!+s KK ! ! #"DO t334 >EAr>$(OO$8$8!$<>>E>$(OO$8$8!$<>>E  " "'577EGG4))3u > >  r6c f|jjt|jjj Dcic]P}||j |jdj|jjffRc}|jycc}w)z9Push the current view limits and position onto the stack.TN) rpushr rrMr _get_view get_positionrnrrs r4r zNavigationToolbar2.push_currentr s    ;;--22 4 bllnt,335(//13444 5 6   " 4sAB. c|j}|yt|j}|D]@\}\}\}}|j||j |d|j |dB|j j y)zi Update the viewlim and position from the view and position stack for each Axes. Noriginalactive)rrmr _set_view _set_positionrr)rInav_inforrviewpos_orig pos_actives r4rzNavigationToolbar2._update_view} s ??$   X^^%&27 3 .B.-* LL    Xz 2   Z 2  3 r6ctdr9jjjjj yddlm}tjddi5tjj|dddddjd jj}|jd tjjj|_jj!d fd fd}|jj!d |j jS#1swYxYw)N subplot_toolrrrr )r)figsizezSubplot configuration toolg?)toprc$jSr)r)ers r4rz7NavigationToolbar2.configure_subplots.. sW__%6r6c@jj`yr)rr3rY)r_r2rIs r4on_tool_fig_closez@NavigationToolbar2.configure_subplots..on_tool_fig_close s KK & &s +!r6)rYrYrMrrrrrr rc_contextrrrsubplots_adjustr SubplotToolr/)rIrrtool_figrar2rs` @@r4rz%NavigationToolbar2.configure_subplots s 4 (    $ $ + + 3 3 8 8 : , ^^Y/ 0 P4;;'33F64JBOG P  !=>>>((  S )#// 0B0BHMkk%% 68 " ##M3DE     P Ps &-E  E)ct)a Save the current figure. Backend implementations may choose to return the absolute path of the saved file, if any, as a string. If no file is created then `None` is returned. If the backend does not implement this functionality then `NavigationToolbar2.UNKNOWN_SAVED_STATUS` is returned. Returns ------- str or `NavigationToolbar2.UNKNOWN_SAVED_STATUS` or `None` The filepath of the saved figure. Returns `None` if figure is not saved. Returns `NavigationToolbar2.UNKNOWN_SAVED_STATUS` when the backend does not provide the information. rUrs r4rgzNavigationToolbar2.save_figure s *"!r6cX|jj|jy)zReset the Axes stack.N)rclearrrs r4r&zNavigationToolbar2.update s    "r6cy)z*Enable or disable the back/forward button.NrLrs r4rz&NavigationToolbar2.set_history_buttons rPr6N)'r!r"r#r$ toolitemsobjectUNKNOWN_SAVED_STATUSrCrrrrbrcrrerr staticmethodrrrrrdrrrrrrfr%rr-rr rrrgr&rrLr6r4rr sL I"8#&= %   6"**> )3j:$*&78H9(   :;(JKIL44&'R # $!.".# 9r6rcNeZdZdZdZ dZdZd dZdZdZ dZ d Z d Z d Z y )ToolContainerBasez Base class for all tool containers, e.g. toolbars. Attributes ---------- toolmanager : `.ToolManager` The tools with which this `ToolContainer` wants to communicate. z.pngch|_|jdfd|jdfdy)Ntool_message_eventc:j|jSr)rrr.rIs r4rz,ToolContainerBase.__init__.. s$**5==9r6tool_removed_eventcNj|jjSr)remove_toolitemtoolrGrss r4rz,ToolContainerBase.__init__.. s$..uzz?r6)r|toolmanager_connect)rIr|s` r4rCzToolContainerBase.__init__ s6&'' 9 ; '' ? Ar6cx|j|jj|jjy)zc Capture the 'tool_trigger_[name]' This only gets used for toggled tools. N)toggle_toolitemrwrGtoggledrs r4_tool_toggled_cbkz#ToolContainerBase._tool_toggled_cbk s& UZZ__ejj.@.@Ar6c|jj|}|j|}t|dddu}|j |j ||||j ||r]|jjd|j z|j|jr|j|j dyyy)aV Add a tool to this container. Parameters ---------- tool : tool_like The tool to add, see `.ToolManager.get_tool`. group : str The name of the group to add this tool to. position : int, default: -1 The position within the group to place this tool. r{Nztool_trigger_%sT) r|get_tool_get_image_filenamerZ add_toolitemrGr3rxr|r{rz)rIrwgrouppositionr%toggles r4add_toolzToolContainerBase.add_tool s((.((.y$/t; $))UH!1!16 ;     0 01BTYY1N151G1G I||$$TYY5 r6cZ|jsytjj|jr |j}ndt |divr t dt |jD]'}dt|vs tj|}n t dttj|j |jz }|||j"zfD]B}tjj%|s#tjj'|cS|j|j|j"zt)j*d|jt)j*d|j|j"zfD]g}tjj%|s#t-j.dd |jd  tjj'|cSy#ttf$r t ddwxYw) zResolve a tool icon's filename.Nr%r%zDIf 'tool.image' is an instance variable, it must be an absolute pathz:Failed to locate source file where 'tool.image' is definedz1Failed to find parent class defining 'tool.image'imagesrz Loading icon z from the current directory or from Matplotlib's image directory. This behavior is deprecated since %(since)s and will be removed in %(removal)s; Tool.image should be set to a path relative to the Tool's source file, or to an absolute path.r)r%rrXisabsrZr|r__mro__varsrgetfileOSError TypeErrorr9pathlibrrW_icon_extensionisfileabspathr _get_data_pathr r)rIrwrrysrcfnames r4rz%ToolContainerBase._get_image_filename szz 77== $zzH'$ B77 "?@@Dz)) Vd3i'T%ooc2 V!!TUU7<<,33djj@AH!8d.B.B#BC 1Hww~~h'wwx00 1 JJ JJ-- -  4:: 6  4::8L8L+L M  .E ww~~e$$$]4::.A4$45 wwu-- .$Y/T(*IJOSTTs HH*c>|jj||y)z Trigger the tool. Parameters ---------- name : str Name (id) of the tool triggered from within the container. )senderN)r| trigger_toolrIrGs r4rzToolContainerBase.trigger_tool( s %%d4%8r6ct)a  A hook to add a toolitem to the container. This hook must be implemented in each backend and contains the backend-specific code to add an element to the toolbar. .. warning:: This is part of the backend implementation and should not be called by end-users. They should instead call `.ToolContainerBase.add_tool`. The callback associated with the button click event must be *exactly* ``self.trigger_tool(name)``. Parameters ---------- name : str Name of the tool to add, this gets used as the tool's ID and as the default label of the buttons. group : str Name of the group that this tool belongs to. position : int Position of the tool within its group, if -1 it goes at the end. image : str Filename of the image for the button or `None`. description : str Description of the tool, used for the tooltips. toggle : bool * `True` : The button is a toggle (change the pressed/unpressed state between consecutive clicks). * `False` : The button is a normal button (returns to unpressed state after release). rU)rIrGrrr%r3rs r4rzToolContainerBase.add_toolitem3 s D"!r6ct)a A hook to toggle a toolitem without firing an event. This hook must be implemented in each backend and contains the backend-specific code to silently toggle a toolbar element. .. warning:: This is part of the backend implementation and should not be called by end-users. They should instead call `.ToolManager.trigger_tool` or `.ToolContainerBase.trigger_tool` (which are equivalent). Parameters ---------- name : str Id of the tool to toggle. toggled : bool Whether to set this tool as toggled or not. rU)rIrGr{s r4rzz!ToolContainerBase.toggle_toolitemW s ("!r6ct)a A hook to remove a toolitem from the container. This hook must be implemented in each backend and contains the backend-specific code to remove an element from the toolbar; it is called when `.ToolManager` emits a ``tool_removed_event``. Because some tools are present only on the `.ToolManager` but not on the `ToolContainer`, this method must be a no-op when called on a tool absent from the container. .. warning:: This is part of the backend implementation and should not be called by end-users. They should instead call `.ToolManager.remove_tool`. Parameters ---------- name : str Name of the tool to remove. rUrs r4rvz!ToolContainerBase.remove_toolitemm s ,"!r6ct)z Display a message on the toolbar. Parameters ---------- s : str Message text. rUrRs r4rzToolContainerBase.set_message s "!r6N)r\)r!r"r#r$rrCr|rrrrrzrvrrLr6r4roro sDO AB62%.N 9""H","0 "r6rocreZdZdZdZeZdZedZ edZ edZ edddZ e dZy) _BackendunknownNcfddlm}|jd|}||i|}|j||S)z%Create a new figure manager instance.rr FigureClass)rrrnew_figure_manager_given_figure)ryrrrrfig_clsrs r4new_figure_managerz_Backend.new_figure_manager s9 -**]F3t&v&223<-N-N N J((,=,I,II  "n&6nn&G((*'7 !r6rctj}|sy|D]} |j|jy|Fttjjddd}t|d}| xr t }|r|jyy#t$r(}t j t |Yd}~d}~wwxYw)z Show all figures. `show` blocks by calling `mainloop` if *block* is ``True``, or if it is ``None`` and we are not in `interactive` mode and if IPython's ``%matplotlib`` integration has not been activated. Nrrr)rrrryr rr9mainlooprZrrrrYrrs r4rz _Backend.show s++-  -G -  - <<   ="#++//2E"FPTUK#K=M%%>n.>*>E  LLN # -""3s8,, -sB C "CC c dD]4}ttjj|t |6Gfddt }ttjjd|S)N)backend_versionr< FigureManagerrrrrceZdZfdZy)_Backend.export..Showc$jSr)r)rIrys r4rz&_Backend.export..Show.mainloop s||~%r6N)r!r"r#rrxsr4Showr s &r6r)setattrrrr"rZShowBase)ryrGrs` r4exportz_Backend.export sd KD CKK/wsD7I J K &8 &  CNN+VT: r6)r!r"r#rr<rwrrrIrrrrrmrrLr6r4rr s OL&M H ==99 + +<r6rceZdZdZddZy)rz} Simple base class to generate a ``show()`` function in backends. Subclass must override ``mainloop()`` method. Nc&|j|S)Nr)r)rIrs r4__call__zShowBase.__call__syyuy%%r6r)r!r"r#r$rrLr6r4rr s  &r6rrrM)_r$ collectionsr contextlibrrrenumrrrr:rrJrloggingrrrcrhrr<r:r numpyr matplotlibrr r rr r rrrrrrrmatplotlib._pylab_helpersrmatplotlib.backend_managersrmatplotlib.cbookrmatplotlib.layout_enginermatplotlib.pathrmatplotlib.texmanagerrmatplotlib.transformsrmatplotlib._enumsrr getLoggerr!rPr0r/r5r>r@r rrrrrrrrr!r(r/r?rRrUr\rsrurtrwr9ryrwcursorsr9rrrorrrLr6r4rsD6#==   %@@@@*3(< ,*1w" $ - . %  &    % & % & " , , - , , , * , - , - , - -$-& `+`+FH=H=V ZZz8!!6<%<(777E7t'i)i)X.%.%b"}"L!"AJ<@$ ?8.8.vJ J ZJ8Z& i M#M#` -- =C =r9r9jH"H"VeeP&x&r6