K i1ddlmZddlmZddlmZddlmcmcm Z ddl m Z dZ dZ Gdd e jZy) )Callable)Basic) import_moduleN)latexcRt|tr t|dSt|S)Ninline)mode) isinstancerrstr)labels z/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/plotting/backends/matplotlibbackend/matplotlib.py _str_or_latexr s#%U** u:cg}g}t|r|D]}|d}|d}|j|j|j|j|jdg|j|j|j|j|jdg||fS|jd|jd||fS)zi Returns lists for matplotlib ``fill`` command from a list of bounding rectangular intervals rN)NNNN)lenextendstartend) interval_listxlistylist intervals intervalx intervalys r _matplotlib_listrs E E =& AI!! I!! I LL)//9??#--> ? LL)//9==#--$@ A  A %<  -. -. %<rcXeZdZdZfdZdZed dZdZdZ dZ dZ d Z xZ S) MatplotlibBackendzd This class implements the functionalities to use Matplotlib with SymPy plotting functions. ct||i|tddgdidtf|_|jj |_|jj|_|jjj|_ |jdd|_ |jdk7r-t|jd|jd z |_ |jd d|_|jd d|_y) N matplotlibfromlist)pyplotcm collectionsz1.1.0) import_kwargsmin_module_versioncatch aspect_ratioautorrfigax)super__init__r RuntimeErrorr r"pltr#r$LineCollectiongetaspectfloatpop _plotgrid_fig _plotgrid_ax)selfserieskwargs __class__s r r-zMatplotlibBackend.__init__0s &+F+' %'FG&|o???))//$$"oo99HHjj8 ;;&  A/$++a.@DK$ZZt4"JJtT2rcd}|jR|j|_|j|_t d|j Ds||jyy|j j|j|_t d|j Dr%|jjdddd|_y|jjddd|_||jy)Nc`|jdjd|jdjd|jdjd|jdjd|jj d|j j dy)Nleftzerorightnonebottomtop)spines set_position set_colorxaxisset_ticks_positionyaxis)r+s r set_spinesz4MatplotlibBackend._create_figure..set_spinesAs IIf  * *6 2 IIg  ( ( 0 IIh  , ,V 4 IIe  & &v . HH ' ' 1 HH ' ' /rc34K|]}|jywNis_3D.0ss r z3MatplotlibBackend._create_figure..Ls51qww5)figsizec34K|]}|jywrKrLrNs r rQz3MatplotlibBackend._create_figure..Ps1q1771rRr3d) projection) r5r*r6r+any_seriesr/figuresize add_subplot)r7rIs r _create_figurez MatplotlibBackend._create_figure@s 0    )))DH''DG5 55477#6xxtyy9DH1DLL11((..q!Q4.H((..q!Q7477#rctd}|d}|||f}nd}||f}|jj|jj dd|}|jj |dd|ddgdS)a Convert two list of coordinates to a list of segments to be used with Matplotlib's :external:class:`~matplotlib.collections.LineCollection`. Parameters ========== x : list List of x-coordinates y : list List of y-coordinates z : list List of z-coordinates for a 3D line. numpyNr)axis)rmaarrayTreshape concatenate)xyznpdimpointss r get_segmentszMatplotlibBackend.get_segmentsVs 7 # =CAYFCVFV$&&..r1c:uu  &"+vabz!: CCrc Ptd}tdddgi}ggg}}}|D]}|jr|jr|j\} } } n|j\} } t |j t tfst|j rT|j| | } |j| } | j|j|j| t|j}|j!| | ||j \}|j"r|j$|j0|j&r=|j\} } }} t |j t tfst|j rk|j(j*}|j| | |} |j-| } | j|j|j| n5t|j}|j!| | |||j |j/|j0|j/|j2|j/|j4z|j6rH|jr|j\} } }}}n|j\} } }|j9| | |t;|j<d|j<j>ddd } t |j@tt tBfr=|j}|jE|jF}| j|n| jI|j@|j/|j0|j/|j2|j/|j4|jJr|j}tM|d k(r2tO|d \} } |jQ| | |j d +|jRjTjV}|d|j g}|\}}}}|dk(r|j%|||||jY|||||jZr|j\dk(r(|j |j^i|j`|j\dk(r(|jb|j^i|j`|j\dk(r(|jd|j^i|j`K|j\dk(s\|jg|jRjhjj|j^i|j`tmdjo||j(jp}t ||s1|js|ju|jwn8|rS|jy|}|j{|ddd f|j}|dddff}|j|n|jd dg|rS|jy|}|j{|ddd f|j}|dddff}|j|n|jd dg|rS|jy|}|j{|ddd f|j}|dddff}|j|n|jd dg|jr't ||s|j|j|jr't ||s|j|jt ||r|jRjdk\r|j|j|jr"|j} t ||rn| dk(r=|jdjd|jdjdn| dk(r{|j\}!}"|j\}#}$|!|"zd krdnd}%|#|$zd krdnd}&|jdj|%|jdj|&nF|jdjd| d f|jdjd| df|js|j|jr5|jr%|jj|j|jr6|j|j|j|j|jr|j|j|jr(t|j}'|j|'d |jr(t|j}(|j|(d! t ||r4|jr(t|j})|j|)d! |jr|j|j|jr|j|j|jj|jy)"Nr^ mpl_toolkitsr!mplot3d)r%)r colorviridisrg?)cmaprstridecstride linewidthr`rNone) facecolor edgecolorwhitecontour)rtmarkers annotationsfill rectangleszc{} is not supported in the SymPy plotting module with matplotlib backend. Please report this issue.)scalexscaleyz1.2.0centerr=rAr))datarr)rr)position)rr)cr is_2Dline is_parametricget_datar line_colorintr3callablernr0 set_arrayget_color_arrayadd_collectionrr plot is_contourr| is_3Dlinerqart3dLine3DCollectionappend_xlim_ylim_zlim is_3Dsurface plot_surfacegetattrr#jet surface_colorrrfrZrE is_implicitrrrr colorsListedColormapcontourf is_generictypeargs rendering_kwannotate fill_between add_patchpatches RectangleNotImplementedErrorformatAxes3Dautoscale_viewget_autoscalex_onget_autoscaley_onrdaminamaxset_xlimset_ylimset_zlimxscale set_xscaleyscale set_yscale __version__set_autoscale_on autoscale axis_centerrCrDget_xlimget_ylimrb set_axis_offlegendlegend_ set_visiblemargin set_xmargin set_ymargintitle set_titlexlabel set_xlabelylabel set_ylabelzlabel set_zlabelxlimylimr+ set_aspectr2)*r7r8r+rkrpxlimsylimszlimsrPrhriparamsegments collectionlbllinerjruv color_arrayrmrcolormapxarrayyarrayzarray plot_typerrrzlimvalxlxhylyhpos_left pos_bottomxlblylblzlbls* r _process_seriesz!MatplotlibBackend._process_seriesps 7 #$ : {*CE !"beuW !A{{??"#**,KAq%::J(():):)<=%%j1'0CGGAq1<5FFFI I- 666 I FFF J66Y&BGGQVV6q~~6VV},BKK:1>>:VVv%#BOOQVV>q~~>VV|+LL9//99VV7'(~~78*IVBZ!!iW !r%%,,"f%   ++-++-  / ad ,bggeAqDk.BC D! QF#ad ,bggeAqDk.BC D! QF#ad ,bggeAqDk.BC D! QF# ;;z"f5 MM$++ & ;;z"f5 MM$++ &"f%)D)D)O    /   ""C"f% &!..x8 (#00:BB*,R%1*;(,.rEQJ[H  &!..x8 (#00< &!..A/?@ (#00&#a&1AByy OO  ;;yy{ &&t{{3 ;; NN4;; ' NN4;; ' :: LL $ ;; -D MM$M 0 ;; -D MM$M 0 b& !dkk -D MM$M 0 99 KK " 99 KK " 4;;'rcp|j|j|j|jy)za Iterates over every ``Plot`` object and further calls _process_series() N)r\rrXr+r7s r process_seriesz MatplotlibBackend.process_series&s(  T\\4773rc|jtjr5|jj |j j y|jyrK)r base_backend_showr* tight_layoutr/showclosers r rzMatplotlibBackend.show.s?     HH ! ! # HHMMO JJLrcZ|j|jj|yrK)rr*savefig)r7paths r savezMatplotlibBackend.save9s   rcN|jj|jyrK)r/rr*rs r rzMatplotlibBackend.close=s txx rrK)__name__ __module__ __qualname____doc__r-r\ staticmethodrnrrrrr __classcell__)r:s@r rr+sC3 $,DD2s(l4 !rr)collections.abcrsympy.core.basicrsympy.externalr$sympy.plotting.backends.base_backendplottingbackendsrsympy.printing.latexrrrPlotrrr r s5$"(;;& 0S! ))S!r