§
    ³[6gé.  ã                   ób   — d Z ddlZddlZddlmZ ddlZddlmZ ddlmZ  G d„ de	¦  «        Z
dS )	z•
Matplotlib Exporter
===================
This submodule contains tools for crawling a matplotlib figure and exporting
relevant pieces to a renderer.
é    Né   )Úutils)Ú
transforms)ÚFigureCanvasAggc                   ót   — e Zd ZdZdd„Zd„ Ze	 dd„¦   «         Zd„ Zd	„ Z	d
„ Z
dd„Zdd„Zdd„Z	 dd„Zd„ ZdS )ÚExporteraý  Matplotlib Exporter

    Parameters
    ----------
    renderer : Renderer object
        The renderer object called by the exporter to create a figure
        visualization.  See mplexporter.Renderer for information on the
        methods which should be defined within the renderer.
    close_mpl : bool
        If True (default), close the matplotlib figure as it is rendered. This
        is useful for when the exporter is used within the notebook, or with
        an interactive matplotlib backend.
    Tc                 ó"   — || _         || _        d S ©N)Ú	close_mplÚrenderer)Úselfr   r   s      úg/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/plotly/matplotlylib/mplexporter/exporter.pyÚ__init__zExporter.__init__   s   € Ø"ˆŒØ ˆŒˆˆó    c                 óü   — |j         €t          |¦  «        }|                     t          j        ¦   «         d|j        ¬¦  «         | j        rddlm} | 	                    |¦  «         |  
                    |¦  «         dS )z¥
        Run the exporter on the given figure

        Parmeters
        ---------
        fig : matplotlib.Figure instance
            The figure to export
        NÚpng)ÚformatÚdpir   )Úcanvasr   ÚsavefigÚioÚBytesIOr   r   Úmatplotlib.pyplotÚpyplotÚcloseÚ	crawl_fig)r   Úfigr   Úplts       r   ÚrunzExporter.run#   s|   € ð Œ:ÐÝ$ SÑ)Ô)ˆFØ�Š•B”J‘L”L¨°C´GˆÑ<Ô<Ð<ØŒ>ð 	Ø+Ð+Ð+Ð+Ð+Ð+à�IŠI�c‰NŒNˆNØ�Š�sÑÔÐÐÐr   NFc                 óÆ  — t          | t          j        ¦  «        rt          j        d¦  «         |�|�| |z
                       |¦  «        }|} d}|�Wd|j        fd|j        fd|j        j	        fdt          j
        ¦   «         ffD ]#\  }}|                      |¦  «        r	|| |z
  } } nŒ$|�1|r||                      |¦  «        | fS ||                      |¦  «        fS |r|| fS |S )a?  Process the transform and convert data to figure or data coordinates

        Parameters
        ----------
        transform : matplotlib Transform object
            The transform applied to the data
        ax : matplotlib Axes object (optional)
            The axes the data is associated with
        data : ndarray (optional)
            The array of data to be transformed.
        return_trans : bool (optional)
            If true, return the final transform of the data
        force_trans : matplotlib.transform instance (optional)
            If supplied, first force the data to this transform

        Returns
        -------
        code : string
            Code is either "data", "axes", "figure", or "display", indicating
            the type of coordinates output.
        transform : matplotlib transform
            the transform used to map input data to output data.
            Returned only if return_trans is True
        new_data : ndarray
            Data transformed to match the given coordinate code.
            Returned only if data is specified
        zMBlended transforms not yet supported. Zoom behavior may not work as expected.NÚdisplayÚdataÚaxesÚfigure)Ú
isinstancer   ÚBlendedGenericTransformÚwarningsÚwarnÚ	transformÚ	transDataÚ	transAxesr$   ÚtransFigureÚIdentityTransformÚcontains_branch)r)   Úaxr"   Úreturn_transÚforce_transÚcodeÚcÚtranss           r   Úprocess_transformzExporter.process_transform7   s9  € õ> �i¥Ô!CÑDÔDð 	ÝŒMð:ñô ð ð
 Ð"ØÐØ! KÑ/×:Ò:¸4Ñ@Ô@�Ø#ˆIàˆØˆ>à˜œÐ&Ø˜œÐ&Ø˜2œ9Ô0Ð1Ø�JÔ8Ñ:Ô:Ð;ð	ð ð ‘��5ð ×,Ò,¨UÑ3Ô3ð Ø'(¨)°eÑ*;˜)�DØ�Eðð ÐØð 7Ø˜Y×0Ò0°Ñ6Ô6¸	ÐAÐAà˜Y×0Ò0°Ñ6Ô6Ð6Ð6àð Ø˜Y�Ð&à�r   c                 óÔ   — | j                              |t          j        |¦  «        ¬¦  «        5  |j        D ]}|                      |¦  «         Œ	 ddd¦  «         dS # 1 swxY w Y   dS )z%Crawl the figure and process all axes)r   ÚpropsN)r   Údraw_figurer   Úget_figure_propertiesr#   Úcrawl_ax)r   r   r/   s      r   r   zExporter.crawl_figx   s¸   € àŒ]×&Ò&¨3µeÔ6QÐRUÑ6VÔ6VÐ&ÑWÔWð 	"ð 	"Ø”hð "ð "�Ø—’˜bÑ!Ô!Ð!Ð!ð"ð	"ð 	"ð 	"ñ 	"ô 	"ð 	"ð 	"ð 	"ð 	"ð 	"ð 	"ð 	"øøøð 	"ð 	"ð 	"ð 	"ð 	"ð 	"s   ¯ AÁA!Á$A!c                 ó8  — | j                              |t          j        |¦  «        ¬¦  «        5  |j        D ]}|                      ||¦  «         Œ|j        D ]}|                      ||¦  «         Œt          |j	        j
        |j        j
        |j        gg d¢¦  «        D ]G\  }}t          |d¦  «        r2|                     ¦   «         r|                      |||j        |¬¦  «         ŒH|j        D ]7}t#          |t$          j        j        ¦  «        r|                      ||¦  «         Œ8|j        D ]}|                      ||¦  «         Œ|j        D ]}|                      ||¦  «         Œ|j        D ]}|                      ||¦  «         Œ|                     ¦   «         }	|	�gt          j        ||	¦  «        }
| j                              |	|
¬¦  «        5  |
d         r|                      ||	¦  «         ddd¦  «         n# 1 swxY w Y   ddd¦  «         dS # 1 swxY w Y   dS )z.Crawl the axes and process all elements within)r/   r7   )ÚxlabelÚylabelÚtitleÚget_text)r1   Ú	text_typeN)Úlegendr7   Úvisible)r   Ú	draw_axesr   Úget_axes_propertiesÚlinesÚ	draw_lineÚtextsÚ	draw_textÚzipÚxaxisÚlabelÚyaxisr>   Úhasattrr?   r+   Úartistsr%   Ú
matplotlibÚtextÚTextÚpatchesÚ
draw_patchÚcollectionsÚdraw_collectionÚimagesÚ
draw_imageÚ
get_legendÚget_legend_propertiesÚdraw_legendÚcrawl_legend)r   r/   ÚlinerP   ÚttpÚartistÚpatchÚ
collectionÚimagerA   r7   s              r   r:   zExporter.crawl_ax~   sÊ  € àŒ]×$Ò$¨µ%Ô2KÈBÑ2OÔ2OÐ$ÑPÔPð 	6ð 	6Øœð )ð )�Ø—’˜r 4Ñ(Ô(Ð(Ð(Øœð )ð )�Ø—’˜r 4Ñ(Ô(Ð(Ð(Ý Ø”” ¤¤°´Ð:Ø-Ð-Ð-ñô ð Vð V‘	��cõ ˜4 Ñ,Ô,ð V°·²±´ð VØ—N’N 2 t¸¼ÐQT�NÑUÔUÐUøØœ*ð /ð /�å˜f¥j¤oÔ&:Ñ;Ô;ð /Ø—N’N 2 vÑ.Ô.Ð.øØœð +ð +�Ø—’  EÑ*Ô*Ð*Ð*Ø œnð 5ð 5�
Ø×$Ò$ R¨Ñ4Ô4Ð4Ð4Øœð +ð +�Ø—’  EÑ*Ô*Ð*Ð*à—]’]‘_”_ˆFØÐ!ÝÔ3°B¸Ñ?Ô?�Ø”]×.Ò.°fÀEÐ.ÑJÔJð 6ð 6Ø˜YÔ'ð 6Ø×)Ò)¨"¨fÑ5Ô5Ð5ð6ð 6ð 6ñ 6ô 6ð 6ð 6ð 6ð 6ð 6ð 6øøøð 6ð 6ð 6ð 6ð3	6ð 	6ð 	6ñ 	6ô 	6ð 	6ð 	6ð 	6ð 	6ð 	6ð 	6ð 	6øøøð 	6ð 	6ð 	6ð 	6ð 	6ð 	6s6   ¯FHÇG7Ç+HÇ7G;	Ç;HÇ>G;	Ç?HÈHÈHc                 ó  — t          t          j        |j        d¬¦  «        ¦  «        }|                     |j        ¦  «         |D �]Â}|                     d|                     ¦   «         z   ¦  «         t          |t          j
        j        ¦  «        r*|                     |                     ¦   «         dz
  ¦  «         	 t          |t          j
        j        ¦  «        r|                      |||j        ¬¦  «         næt          |t          j        j        ¦  «        r6|                     ¦   «         dk    r|                      |||j        ¬¦  «         n‘t          |t          j        j        ¦  «        r|                      |||j        ¬¦  «         nTt          |t          j        j        ¦  «        r|                      |||j        ¬¦  «         nt3          j        d|z  ¦  «         �Œœ# t6          $ r t3          j        d|z  ¦  «         Y �ŒÀw xY wd	S )
zE
        Recursively look through objects in legend children
        T)ÚskipContainersg    €„.Ar   ©r1   ÚNone)Úforce_pathtransz Legend element %s not impementedN)Úlistr   Úiter_all_childrenÚ_legend_boxÚappendÚlegendPatchÚ
set_zorderÚ
get_zorderr%   rO   rR   ÚFancyBboxPatchÚPatchrS   r+   rP   rQ   r?   rH   rE   ÚLine2DrF   rT   Ú
CollectionrU   r'   r(   ÚNotImplementedError)r   r/   rA   ÚlegendElementsÚchilds        r   r[   zExporter.crawl_legend�   s  € õ ÝÔ# FÔ$6ÀtÐLÑLÔLñ
ô 
ˆð 	×Ò˜fÔ0Ñ1Ô1Ð1Ø#ð 	Jñ 	JˆEà×Ò˜S 5×#3Ò#3Ñ#5Ô#5Ñ5Ñ6Ô6Ð6õ ˜%¥Ô!3Ô!BÑCÔCð 9Ø× Ò  ×!1Ò!1Ñ!3Ô!3°aÑ!7Ñ8Ô8Ð8ðJå˜e¥ZÔ%7Ô%=Ñ>Ô>ð 
NØ—O’O B¨¸2¼<�OÑHÔHÐHÐHÝ ¥z¤Ô';Ñ<Ô<ð NØ—~’~Ñ'Ô'¨6Ò1Ð1ØŸš r¨5¸b¼l˜ÑKÔKÐKøÝ ¥zÔ'7Ô'>Ñ?Ô?ð NØ—N’N 2 u¸"¼,�NÑGÔGÐGÐGÝ ¥zÔ'=Ô'HÑIÔIð NØ×(Ò(¨¨UÀBÄLÐ(ÑQÔQÐQÐQå”MÐ"DÀuÑ"LÑMÔMÐMùøÝ&ð Jð Jð JÝ”Ð@À5ÑHÑIÔIÐIÐIÑIðJøøøð+	Jð 	Js   Â<D#G!Ç!!HÈHc                 ó¼  — |                       |                     ¦   «         ||                     ¦   «         |¬¦  «        \  }}t          j        |¦  «        }|d         €|d         dk    rd}t          j        |¦  «        }|d         dv s|d         d	         j        d	k    rd}|                     ¦   «         }|s|r"| j         	                    ||||||¬
¦  «         dS dS )z5Process a matplotlib line and call renderer.draw_linerd   Ú	dasharrayNÚ	drawstyleÚdefaultÚmarker)re   ÚnoneNÚ
markerpathr   )r"   ÚcoordinatesÚ	linestyleÚmarkerstylerK   Úmplobj)
r5   Úget_transformÚ
get_xydatar   Úget_line_styleÚget_marker_styleÚsizeÚ	get_labelr   Údraw_marked_line)	r   r/   r\   r1   r|   r"   r}   r~   rK   s	            r   rF   zExporter.draw_line½   s  € à ×2Ò2Ø×ÒÑ Ô  " d§o¢oÑ&7Ô&7À[ð 3ñ 
ô 
Ñˆ�Tõ Ô(¨Ñ.Ô.ˆ	Ø�[Ô!Ð)¨i¸Ô.DÈ	Ò.QÐ.QØˆIÝÔ,¨TÑ2Ô2ˆà˜Ô!Ð%;Ð;Ð;Ø˜<Ô(¨Ô+Ô0°AÒ5Ð5àˆKØ—’Ñ Ô ˆØð 	˜)ð 	ØŒM×*Ò*ØØ'Ø#Ø'ØØð +ñ ô ð ð ð ð	ð 	r   c                 ó&  — |                      ¦   «         }|rz|                     ¦   «         }|                     ¦   «         }|                      ||||¬¦  «        \  }}t	          j        |¦  «        }	| j                             |||||	|¬¦  «         dS dS )z<Process a matplotlib text object and call renderer.draw_textrd   )rP   Úpositionr|   r@   Ústyler   N)r?   r€   Úget_positionr5   r   Úget_text_styler   rH   )
r   r/   rP   r1   r@   Úcontentr)   rˆ   Úcoordsr‰   s
             r   rH   zExporter.draw_textÖ   s¸   € à—-’-‘/”/ˆØð 	Ø×*Ò*Ñ,Ô,ˆIØ×(Ò(Ñ*Ô*ˆHØ#×5Ò5Ø˜2˜x°[ð  6ñ  ô  ÑˆF�Hõ Ô(¨Ñ.Ô.ˆEØŒM×#Ò#ØØ!Ø"Ø#ØØð $ñ ô ð ð ð ð	ð 	r   c                 óF  — t          j        |                     ¦   «         ¦  «        \  }}|                     ¦   «         }|                      ||||¬¦  «        \  }}t          j        ||                     ¦   «         ¬¦  «        }| j                             |||||¬¦  «         dS )z=Process a matplotlib patch object and call renderer.draw_pathrd   )Úfill)r"   r|   Ú	pathcodesr‰   r   N)	r   ÚSVG_pathÚget_pathr€   r5   Úget_path_styleÚget_fillr   Ú	draw_path)	r   r/   r_   r1   Úverticesr�   r)   r|   r}   s	            r   rS   zExporter.draw_patché   s²   € å#œn¨U¯^ª^Ñ-=Ô-=Ñ>Ô>Ñˆ�)Ø×'Ò'Ñ)Ô)ˆ	Ø $× 6Ò 6Ø�r˜8°ð !7ñ !
ô !
Ñˆ�Xõ Ô(¨°U·^²^Ñ5EÔ5EÐFÑFÔFˆ	ØŒ×ÒØØ#ØØØð 	 ñ 	
ô 	
ð 	
ð 	
ð 	
r   c           
      ó–  ‡ ‡‡‡— |                      ¦   «         \  Š}}}‰                      |‰||¬¦  «        \  }}‰                      ‰‰‰¬¦  «        }	d„ |D ¦   «         }
ˆˆˆ ˆfd„|
D ¦   «         }
|                     ¦   «         }	 d„ |D ¦   «         }n# t          $ r Y nw xY w|                     ¦   «         |                     ¦   «         |                     ¦   «         |j        |                     ¦   «         dœ}dddœ}t          |d	¦  «        r|| 
                    ¦   «                  nd}‰ j                             |
|	||||||¬
¦  «         dS )zAProcess a matplotlib collection and call renderer.draw_collectionrd   c                 ó6   — g | ]}t          j        |¦  «        ‘ŒS © )r   r‘   )Ú.0Úpaths     r   ú
<listcomp>z,Exporter.draw_collection.<locals>.<listcomp>  s"   € ÐBÐBÐB°D�5œ>¨$Ñ/Ô/ÐBÐBÐBr   c                 ój   •— g | ]/}‰                      ‰‰|d          ‰¬¦  «        d         |d         f‘Œ0S )r   rd   r   )r5   )rš   r›   r/   rf   r   r)   s     €€€€r   rœ   z,Exporter.draw_collection.<locals>.<listcomp>  sc   ø€ ð 
ð 
ð 
ð ð ×&Ò&Ø˜r 4¨¤7¸ð 'ñ ô àôð �Q”ð	ð
ð 
ð 
r   c                 ó6   — g | ]}|                      ¦   «         ‘ŒS r™   )Ú
get_matrix)rš   Úts     r   rœ   z,Exporter.draw_collection.<locals>.<listcomp>  s    € ÐGÐGÐG°!˜qŸ|š|™~œ~ÐGÐGÐGr   )Ú	linewidthÚ	facecolorÚ	edgecolorÚalphaÚzorderÚbeforeÚafter)r"   ÚscreenÚget_offset_position)ÚpathsÚpath_coordinatesÚpath_transformsÚoffsetsÚoffset_coordinatesÚoffset_orderÚstylesr   N)Ú_prepare_pointsr5   Úget_transformsÚAttributeErrorÚget_linewidthsÚget_facecolorsÚget_edgecolorsÚ_alpharm   rM   r©   r   Údraw_path_collection)r   r/   r`   rf   Úforce_offsettransÚtransOffsetr­   rª   Úoffset_coordsÚpath_coordsÚprocessed_pathsr¬   r°   Úoffset_dictr¯   r)   s   `` `           @r   rU   zExporter.draw_collectionù   sØ  øøøø€ ð 4>×3MÒ3MÑ3OÔ3OÑ0ˆ�K ¨%à!%×!7Ò!7Ø˜˜WÐ2Cð "8ñ "
ô "
Ñˆ�wð ×,Ò,¨Y¸ÈÐ,ÑXÔXˆàBÐB¸EÐBÑBÔBˆð
ð 
ð 
ð 
ð 
ð 
ð 
ð (ð
ñ 
ô 
ˆð %×3Ò3Ñ5Ô5ˆð	ð HÐG°ÐGÑGÔGˆOˆOøÝð 	ð 	ð 	àˆDð	øøøð
 $×2Ò2Ñ4Ô4Ø#×2Ò2Ñ4Ô4Ø#×2Ò2Ñ4Ô4ØÔ&Ø ×+Ò+Ñ-Ô-ð
ð 
ˆð  (°7Ð;Ð;ˆõ �zÐ#8Ñ9Ô9ðˆK˜
×6Ò6Ñ8Ô8Ô9Ð9àð 	ð 	Œ×*Ò*Ø!Ø(Ø+ØØ,Ø%ØØð 	+ñ 		
ô 		
ð 		
ð 		
ð 		
s   ÂB Â
BÂBc                 óÚ   — | j                              t          j        |¦  «        |                     ¦   «         d|                     ¦   «         |                     ¦   «         dœ|¬¦  «         dS )z>Process a matplotlib image object and call renderer.draw_imager"   )r¤   r¥   )ÚimdataÚextentr|   r‰   r   N)r   rW   r   Úimage_to_base64Ú
get_extentÚ	get_alpharm   )r   r/   ra   s      r   rW   zExporter.draw_image4  so   € àŒ× Ò ÝÔ(¨Ñ/Ô/Ø×#Ò#Ñ%Ô%ØØ!ŸOšOÑ-Ô-¸×9IÒ9IÑ9KÔ9KÐLÐLØð 	!ñ 	
ô 	
ð 	
ð 	
ð 	
r   )T)NNFNr
   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ústaticmethodr5   r   r:   r[   rF   rH   rS   rU   rW   r™   r   r   r   r      sý   € € € € € ðð ð!ð !ð !ð !ðð ð ð( àGKð>ð >ð >ñ „\ð>ð@"ð "ð "ð6ð 6ð 6ð>Jð Jð Jð@ð ð ð ð2ð ð ð ð&
ð 
ð 
ð 
ð" GKð9
ð 9
ð 9
ð 9
ðv
ð 
ð 
ð 
ð 
r   r   )rÈ   r'   r   Ú r   rO   r   Úmatplotlib.backends.backend_aggr   Úobjectr   r™   r   r   ú<module>rÍ      s£   ððð ð €€€Ø 	€	€	€	Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ø !Ð !Ð !Ð !Ð !Ð !Ø ;Ð ;Ð ;Ð ;Ð ;Ð ;ðl
ð l
ð l
ð l
ð l
ˆvñ l
ô l
ð l
ð l
ð l
r   