
    \h1                         S SK Jr  S SKJr  S SKJr  S SKJs  Js  J	r	  S SK
Jr  S rS r " S S	\	R                  5      rg)
    )Callable)Basic)import_moduleN)latexc                 V    [        U [        5      (       a
  [        U SS9$ [        U 5      $ )Ninline)mode)
isinstancer   r   str)labels    l/var/www/auris/envauris/lib/python3.13/site-packages/sympy/plotting/backends/matplotlibbackend/matplotlib.py_str_or_latexr      s&    %U**u:    c                    / n/ n[        U 5      (       a  U  H  nUS   nUS   nUR                  UR                  UR                  UR                  UR                  S/5        UR                  UR                  UR                  UR                  UR                  S/5        M     X4$ UR                  S5        UR                  S5        X4$ )z]
Returns lists for matplotlib ``fill`` command from a list of bounding
rectangular intervals
r      N)NNNN)lenextendstartend)interval_listxlistylist	intervals	intervalx	intervalys         r   _matplotlib_listr      s    
 EE
=&I!!I!!ILL)//9??#--> ?LL)//9==#--$@ A ' < 	-.-.<r   c                   d   ^  \ rS rSrSrU 4S jrS r\SS j5       rS r	S r
S rS	 rS
 rSrU =r$ )MatplotlibBackend+   z[This class implements the functionalities to use Matplotlib with SymPy
plotting functions.
c                   > [         TU ]  " U0 UD6  [        SS/ SQ0S[        4S9U l        U R                  R
                  U l        U R                  R                  U l        U R                  R                  R                  U l	        UR                  SS5      U l        U R                  S:w  a-  [        U R                  S   5      U R                  S	   -  U l        UR                  S
S 5      U l        UR                  SS 5      U l        g )N
matplotlibfromlist)pyplotcmcollectionsz1.1.0)import_kwargsmin_module_versioncatchaspect_ratioautor   r   figax)super__init__r   RuntimeErrorr!   r#   pltr$   r%   LineCollectiongetaspectfloatpop_plotgrid_fig_plotgrid_ax)selfserieskwargs	__class__s      r   r.   MatplotlibBackend.__init__0   s    &+F+'%'FG&|o? ??))//$$"oo99HHjj8;;& A/$++a.@DK $ZZt4"JJtT2r   c                    S nU R                   bW  U R                   U l        U R                  U l        [	        S U R
                   5       5      (       d  U" U R                  5        g g U R                  R                  U R                  S9U l        [	        S U R
                   5       5      (       a"  U R                  R                  SSSSS9U l        g U R                  R                  SSS5      U l        U" U R                  5        g )Nc                 `   U R                   S   R                  S5        U R                   S   R                  S5        U R                   S   R                  S5        U R                   S   R                  S5        U R                  R	                  S5        U R
                  R	                  S5        g )Nleftzerorightnonebottomtop)spinesset_position	set_colorxaxisset_ticks_positionyaxis)r,   s    r   
set_spines4MatplotlibBackend._create_figure.<locals>.set_spinesA   s    IIf**62IIg((0IIh,,V4IIe&&v.HH''1HH''/r   c              3   8   #    U  H  oR                   v   M     g 7fNis_3D.0ss     r   	<genexpr>3MatplotlibBackend._create_figure.<locals>.<genexpr>L   s     51ww   )figsizec              3   8   #    U  H  oR                   v   M     g 7frN   rO   rQ   s     r   rT   rU   P   s     1Lq77LrV   r   3d)
projection)
r6   r+   r7   r,   any_seriesr0   figuresizeadd_subplot)r8   rK   s     r   _create_figure MatplotlibBackend._create_figure@   s    	0 )))DH''DG5555477# 6 xxtyy9DH1DLL111((..q!Q4.H((..q!Q7477#r   c                     [        S5      nUb  SnXU4nOSnX4nUR                  R                  U5      R                  R	                  SSU5      nUR                  R                  USS USS /SS9$ )a6  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.
numpyN      r   )axis)r   maarrayTreshapeconcatenate)xyznpdimpointss         r   get_segmentsMatplotlibBackend.get_segmentsV   s      7#=CAYFCVFV$&&..r1c:uu  &"+vabz!: CCr   c                    [        S5      n[        SSS/0S9n/ / / pvnU GH  nUR                  (       a  UR                  (       a  UR                  5       u  pnOUR                  5       u  p[	        UR
                  [        [        45      (       d  [        UR
                  5      (       aT  U R                  X5      nU R                  U5      nUR                  UR                  5       5        UR                  U5        M  [        UR                  5      nUR!                  XXR
                  S9u  nGM  UR"                  (       a   UR$                  " UR                  5       6   GMD  UR&                  (       GaA  UR                  5       u  pnn[	        UR
                  [        [        45      (       d  [        UR
                  5      (       aj  UR(                  R*                  nU R                  XU5      nUR-                  U5      nUR                  UR                  5       5        UR                  U5        O0[        UR                  5      nUR!                  XUXR
                  S9  UR/                  UR0                  5        UR/                  UR2                  5        UR/                  UR4                  5        GM  UR6                  (       GaM  UR                  (       a  UR                  5       u  pnnnOUR                  5       u  pnUR9                  XU[;        U R<                  SU R<                  R>                  5      SSS	S
9n[	        UR@                  [        [        [B        45      (       a=  UR                  5       nURE                  URF                  5      nUR                  U5        OURI                  UR@                  5        UR/                  UR0                  5        UR/                  UR2                  5        UR/                  UR4                  5        GM  URJ                  (       a  UR                  5       n[M        U5      S:X  a.  [O        US   5      u  pURQ                  XUR
                  SS9  GMT  U RR                  RT                  RV                  nU" SUR
                  /5      nUu  nnnnUS:X  a  UR%                  UUUUS9  GM  URY                  UUUUS9  GM  URZ                  (       Ga
  UR\                  S:X  a)  UR                   " UR^                  0 UR`                  D6  GM
  UR\                  S:X  a)  URb                  " UR^                  0 UR`                  D6  GMC  UR\                  S:X  a)  URd                  " UR^                  0 UR`                  D6  GM|  UR\                  S:X  aL  URg                  U RR                  Rh                  Rj                  " UR^                  0 UR`                  D65        GM  GM  [m        SRo                  U5      5      e   UR(                  Rp                  n[	        UU5      (       d.  URs                  URu                  5       URw                  5       S9  GOGU(       aS  URy                  U5      nUR{                  US S 2S4   5      UR}                  US S 2S4   5      4nUR                  U5        OUR                  SS/5        U(       aS  URy                  U5      nUR{                  US S 2S4   5      UR}                  US S 2S4   5      4nUR                  U5        OUR                  SS/5        U(       aS  URy                  U5      nUR{                  US S 2S4   5      UR}                  US S 2S4   5      4nUR                  U5        OUR                  SS/5        U R                  (       a,  [	        UU5      (       d  UR                  U R                  5        U R                  (       a,  [	        UU5      (       d  UR                  U R                  5        [	        UU5      (       a  U RR                  R                  S:  a  UR                  U R                  5        U R                  (       Ga+  U R                  n [	        UU5      (       a  GOU S:X  a=  UR                  S   R                  S5        UR                  S   R                  S5        OU S:X  a}  UR                  5       u  n!n"UR                  5       u  n#n$U!U"-  S::  a  SOSn%U#U$-  S::  a  SOSn&UR                  S   R                  U%5        UR                  S   R                  U&5        OFUR                  S   R                  SU S   45        UR                  S   R                  SU S   45        U R                  (       d  UR                  5         U R                  (       a:  UR                  5       (       a%  UR                  R                  U R                  5        U R                  (       a6  UR                  U R                  5        UR                  U R                  5        U R                  (       a  UR                  U R                  5        U R                  (       a%  [        U R                  5      n'UR                  U'SS 9  U R                  (       a%  [        U R                  5      n(UR                  U(S!S 9  [	        UU5      (       a6  U R                  (       a%  [        U R                  5      n)UR                  U)S!S 9  U R                  (       a  UR                  U R                  5        U R                  (       a  UR                  U R                  5        U R                  R                  U R                  5        g )"Nrc   mpl_toolkitsr"   mplot3d)r&   )r   colorviridisr   g?)cmaprstridecstride	linewidthre   r   None)	facecolor	edgecolorwhitecontour)rz   markersannotationsfill
rectangleszc{} is not supported in the SymPy plotting module with matplotlib backend. Please report this issue.)scalexscaleyz1.2.0centerr?   rC   r*   )datar   r   )r   r   )position)r   r   )cr   	is_2Dlineis_parametricget_datar
   
line_colorintr4   callablers   r1   	set_arrayget_color_arrayadd_collectionr   r   plot
is_contourr   	is_3Dlinerw   art3dLine3DCollectionappend_xlim_ylim_zlimis_3Dsurfaceplot_surfacegetattrr$   jetsurface_colorr   rk   r^   rG   is_implicitr   r   r   r!   colorsListedColormapcontourf
is_generictypeargsrendering_kwannotatefill_between	add_patchpatches	RectangleNotImplementedErrorformatAxes3Dautoscale_viewget_autoscalex_onget_autoscaley_onri   aminamaxset_xlimset_ylimset_zlimxscale
set_xscaleyscale
set_yscale__version__set_autoscale_on	autoscaleaxis_centerrE   rF   get_xlimget_ylimrg   set_axis_offlegendlegend_set_visiblemarginset_xmarginset_ymargintitle	set_titlexlabel
set_xlabelylabel
set_ylabelzlabel
set_zlabelxlimylimr,   
set_aspectr3   )*r8   r9   r,   rp   rv   xlimsylimszlimsrS   rm   rn   paramsegments
collectionlbllinero   r   uvcolor_arrayrr   r   colormapxarrayyarrayzarray	plot_typer   r   r   zlimvalxlxhylyhpos_left
pos_bottomxlblylblzlbls*                                             r   _process_series!MatplotlibBackend._process_seriesp   s   7#$:	{*CE
 !"beA{{??"#**,KA%::<DAq||c5\:: ..#006H!%!4!4X!>J(():):)<=%%j1'0CGGA<<GHED

AJJL)!"aq||c5\:: ..(0066E#00q9H!&!7!7!AJ(():):)<=%%j1'0CGGA!3llGCQWW%QWW%QWW%??$%JJLMA!QjjlGA!__Q1 )TWW[[AqC - 9
 aoosH/EFF"#"3"3"5K"-"5"5k6F6F"GK((5((9QWW%QWW%QWW%v;!#+F1I6DAGGAALLFGK
 &*__%;%;%J%JN-w.EFH8>5FFFI I-

666
IFFFJ66Y&GGQVV6q~~6VV},KK:1>>:VVv%OOQVV>q~~>VV|+LL//99VV7'(~~78 , *IVBZ! !i r %%,,"f%%++-++-  / ad,bggeAqDk.BCD!QF#ad,bggeAqDk.BCD!QF#ad,bggeAqDk.BCD!QF#
 ;;z"f55MM$++&;;z"f55MM$++&"f%%)D)D)O/""C"f%%		&!..x8		(#00:BB*,R%1*;(,.rEQJ[H
		&!..x8		(#00<		&!..A/?@		(#00&#a&1AByy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;;'r   c                 p    U R                  5         U R                  U R                  U R                  5        g)zI
Iterates over every ``Plot`` object and further calls
_process_series()
N)r`   r   r\   r,   r8   s    r   process_series MatplotlibBackend.process_series&  s(    
 	T\\4773r   c                     U R                  5         [        R                  (       a5  U R                  R	                  5         U R
                  R                  5         g U R                  5         g rN   )r   base_backend_showr+   tight_layoutr0   showcloser   s    r   r   MatplotlibBackend.show.  s?     HH!!#HHMMOJJLr   c                 Z    U R                  5         U R                  R                  U5        g rN   )r   r+   savefig)r8   paths     r   saveMatplotlibBackend.save9  s     r   c                 N    U R                   R                  U R                  5        g rN   )r0   r   r+   r   s    r   r   MatplotlibBackend.close=  s    txx r   )	r1   r7   r6   r3   r,   r$   r+   r!   r0   rN   )__name__
__module____qualname____firstlineno____doc__r.   r`   staticmethodrs   r   r   r   r  r   __static_attributes____classcell__)r;   s   @r   r   r   +   sH    3 $, D D2s(l4	! !r   r   )collections.abcr   sympy.core.basicr   sympy.externalr   $sympy.plotting.backends.base_backendplottingbackendsr   sympy.printing.latexr   r   r   Plotr    r   r   <module>r     s5    $ " ( ; ; &0S!)) S!r   