rL ihdZddlZddlmZGddZej ej y)z* Manage figures for the pyplot interface. N) OrderedDictceZdZdZeZedZedZedZ edZ edZ edZ edZ ed Zed Zed Zedd Zy )GcfaV Singleton to maintain the relation between figures and their managers, and keep track of and "active" figure and manager. The canvas of a figure created through pyplot is associated with a figure manager, which handles the interaction between the figure and the backend. pyplot keeps track of figure managers using an identifier, the "figure number" or "manager number" (which can actually be any hashable value); this number is available as the :attr:`number` attribute of the manager. This class is never instantiated; it consists of an `OrderedDict` mapping figure/manager numbers to managers, and a set of class methods that manipulate this `OrderedDict`. Attributes ---------- figs : OrderedDict `OrderedDict` mapping numbers to managers; the active manager is at the end. cd|jj|d}||j||S)zx If manager number *num* exists, make it the active one and return it; otherwise return *None*. N)figsget set_activeclsnummanagers _/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/_pylab_helpers.pyget_fig_managerzGcf.get_fig_manager!s/ ((,,sD)   NN7 #ctfddDrO}|jj|j|urB|jj |jn |jj }t |dr%|jj|j|jy#t $rYywxYw)a= Destroy manager *num* -- either a manager instance or a manager number. In the interactive backends, this is bound to the window "destroy" and "delete" events. It is recommended to pass a manager instance, to avoid confusion when two managers share the same number. c36K|]}t|ywN)hasattr).0attrr s r zGcf.destroy..7sAdwsD!As)r destroyN_cidgcf) allrrr popKeyErrorrcanvasmpl_disconnectrrr s ` rrz Gcf.destroy,s A.@A AGxx||GKK(G3 W[[) ((,,s+ 7I & NN ) )'// :   s&C CCctfd|jjDd}||j|yy)zDestroy figure *fig*.c3hK|])}|jjk(r|j+ywr)rfigurer )rr figs rrz"Gcf.destroy_fig..Gs.5G~~,,3KK5s/2N)nextrvaluesr)r r"r s ` r destroy_figzGcf.destroy_figDs?5sxx/@56:< ? KK  rct|jjD]7}|jj |j |j 9|jjy)zDestroy all figures.N)listrr$rrrrclearr r s r destroy_allzGcf.destroy_allLsSCHHOO-. G NN ) )'// : OO   rc||jvS)z*Return whether figure number *num* exists.)r)r r s r has_fignumzGcf.has_fignumTschhrcHt|jjS)z!Return a list of figure managers.)r'rr$r s rget_all_fig_managerszGcf.get_all_fig_managersYsCHHOO%&&rc,t|jS)z+Return the number of figures being managed.)lenrr.s rget_num_fig_managerszGcf.get_num_fig_managers^s388}rcv|jr,tt|jjSdS)zz-Gcf._set_new_active_manager..msCNN74KrN) rr mpl_connectrr!r _number get_labelset_window_titler )r r r"labels`` r_set_new_active_managerzGcf._set_new_active_managerhsnw *%nn88$&KMGOnn##kk     $ $U + wrc||j|j<|jj|jy)z"Make *manager* the active manager.N)rr move_to_endr)s rr zGcf.set_activeus,!( W[[)rc|jD]?}|s!|jjjs&|jj Ay)zh Redraw all stale managed figures, or, if *force* is True, all managed figures. N)r/rr!stale draw_idle)r forcer s rdraw_allz Gcf.draw_all{sA //1 +G--33((* +rN)F)__name__ __module__ __qualname____doc__rr classmethodrrr%r*r,r/r2r5r@r rGrrrr s* =D.''GG    ** ++rr)rKatexit collectionsrrregisterr*rMrrrQs3#z+z+z r