
    -Phj9                     r    d dl Z d dlZd dlmZ d dlmZ d dlZd dlZ	d dlm
Z
 ddlmZ  G d de          ZdS )	    N)contextmanager)Version)
transforms   )utilsc                   R   e Zd Zed             Zed             Zed             Zed             Zed             Z	ed             Z
ed             Zed             Zed	             Zd
 Zd Zd Zd Zd Zd Z	 ddZddZed             Z	 ddZddZ	 ddZ	 	 	 ddZddZdS )Rendererc                 H    t          | o|                                           S N)boolget_navigateaxs    n/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/plotly/matplotlylib/mplexporter/renderers/base.pyax_zoomablezRenderer.ax_zoomable   s    B,2??,,---    c                 j    t          | o$| j        j        o| j                                                  S r   )r   xaxis_gridOnMajoryaxisget_gridlinesr   s    r   ax_has_xgridzRenderer.ax_has_xgrid   -    BM280MRX5K5K5M5MNNNr   c                 j    t          | o$| j        j        o| j                                                  S r   )r   r   r   r   r   s    r   ax_has_ygridzRenderer.ax_has_ygrid   r   r   c                 6    |                      | j                  S r   )r   _current_axselfs    r   current_ax_zoomablezRenderer.current_ax_zoomable   s     0111r   c                 6    |                      | j                  S r   )r   r   r   s    r   current_ax_has_xgridzRenderer.current_ax_has_xgrid         !1222r   c                 6    |                      | j                  S r   )r   r   r   s    r   current_ax_has_ygridzRenderer.current_ax_has_ygrid"   r#   r   c              #      K   t          | d          r| j        t          j        d           || _        || _        |                     ||           d V  |                     |           d | _        i | _        d S )N_current_figz-figure embedded in figure: something is wrong)figprops)r(   )hasattrr'   warningswarn
_fig_propsopen_figureclose_figurer   r(   r)   s      r   draw_figurezRenderer.draw_figure&   s      4(( 	KT->-JMIJJJS...c""" r   c              #      K   t          | d          r| j        t          j        d           || _        || _        |                     ||           d V  |                     |           d | _        i | _        d S )Nr   z)axes embedded in axes: something is wrong)r   r)   r   )r*   r   r+   r,   	_ax_props	open_axes
close_axesr   r   r)   s      r   	draw_axeszRenderer.draw_axes2   s      4'' 	GD,<,HMEFFF"E***2r   c              #      K   || _         || _        |                     ||           d V  |                     |           d | _         i | _        d S )N)legendr)   )r9   )_current_legend_legend_propsopen_legendclose_legendr   r9   r)   s      r   draw_legendzRenderer.draw_legend>   se      %"e444(((#r   c                     dS )a  
        Begin commands for a particular figure.

        Parameters
        ----------
        fig : matplotlib.Figure
            The Figure which will contain the ensuing axes and elements
        props : dictionary
            The dictionary of figure properties
        N r0   s      r   r.   zRenderer.open_figureJ   	     	r   c                     dS )z
        Finish commands for a particular figure.

        Parameters
        ----------
        fig : matplotlib.Figure
            The figure which is finished being drawn.
        NrA   )r   r(   s     r   r/   zRenderer.close_figureW   	     	r   c                     dS )a
  
        Begin commands for a particular axes.

        Parameters
        ----------
        ax : matplotlib.Axes
            The Axes which will contain the ensuing axes and elements
        props : dictionary
            The dictionary of axes properties
        NrA   r6   s      r   r4   zRenderer.open_axesb   rB   r   c                     dS )z
        Finish commands for a particular axes.

        Parameters
        ----------
        ax : matplotlib.Axes
            The Axes which is finished being drawn.
        NrA   )r   r   s     r   r5   zRenderer.close_axeso   rD   r   c                     dS )a  
        Beging commands for a particular legend.

        Parameters
        ----------
        legend : matplotlib.legend.Legend
                The Legend that will contain the ensuing elements
        props : dictionary
                The dictionary of legend properties
        NrA   r>   s      r   r<   zRenderer.open_legendz   rB   r   c                     dS )z
        Finish commands for a particular legend.

        Parameters
        ----------
        legend : matplotlib.legend.Legend
                The Legend which is finished being drawn
        NrA   )r   r9   s     r   r=   zRenderer.close_legend   rD   r   Nc                 v    ||                      |||||           ||                     |||||           dS dS )a  Draw a line that also has markers.

        If this isn't reimplemented by a renderer object, by default, it will
        make a call to BOTH draw_line and draw_markers when both markerstyle
        and linestyle are not None in the same Line2D object.

        N)	draw_linedraw_markers)r   datacoordinates	linestylemarkerstylelabelmplobjs          r   draw_marked_linezRenderer.draw_marked_line   sT      NN4iGGG"dKeVLLLLL #"r   c                     dg|j         d         dz
  dgz  z   }t          dddi|}|                    d          |d<   |                    d	          |d
<   |                     |||||           dS )a  
        Draw a line. By default, draw the line via the draw_path() command.
        Some renderers might wish to override this and provide more
        fine-grained behavior.

        In matplotlib, lines are generally created via the plt.plot() command,
        though this command also can create marker collections.

        Parameters
        ----------
        data : array_like
            A shape (N, 2) array of datapoints.
        coordinates : string
            A string code, which should be either 'data' for data coordinates,
            or 'figure' for figure (pixel) coordinates.
        style : dictionary
            a dictionary specifying the appearance of the line.
        mplobj : matplotlib object
            the matplotlib plot element which generated this line
        Mr      L	facecolornonecolor	edgecolor	linewidth	edgewidth)rL   rM   	pathcodesstylerQ   NrA   )shapedictpop	draw_path)r   rL   rM   r^   rP   rQ   r]   	pathstyles           r   rJ   zRenderer.draw_line   s    * ETZ]Q.3%77	3363U33	!*w!7!7	+!*{!;!;	+# 	 	
 	
 	
 	
 	
r   c                    t          t          |           t          |                    }t          t          j                  t          d          k     r|t          j        d          g}|d         }t          j        |          dk    rdg}|d         }t          j        |          dk    rdg}| ||||d         |g}t          }|	                    t          t          |j        |           |          S )	z:Build an iterator over the elements of the path collectionz1.4.0N   rZ   r   rX   rW   r[   )maxlenr   mpl__version__npeyesize	itertoolsislicezipmapcycle)	pathspath_transformsoffsetsstylesNrZ   rW   elementsits	            r   _iter_path_collectionzRenderer._iter_path_collection   s     E

CLL)) 3?##gg&6&666&#%6!99+;'	79""I;'	79""I ;
 yyc"(H556:::r   c	           
         |dk    rt          d          |                     ||||          D ]}	|	\  }
}}}}}|
\  }}t          j        |          }|                    |          }|dk    rd}t          j        |          t          j        |          |d|d         |d         d}|                     |||||||	           d
S )aZ  
        Draw a collection of paths. The paths, offsets, and styles are all
        iterables, and the number of paths is max(len(paths), len(offsets)).

        By default, this is implemented via multiple calls to the draw_path()
        function. For efficiency, Renderers may choose to customize this
        implementation.

        Examples of path collections created by matplotlib are scatter plots,
        histograms, contour plots, and many others.

        Parameters
        ----------
        paths : list
            list of tuples, where each tuple has two elements:
            (data, pathcodes).  See draw_path() for a description of these.
        path_coordinates: string
            the coordinates code for the paths, which should be either
            'data' for data coordinates, or 'figure' for figure (pixel)
            coordinates.
        path_transforms: array_like
            an array of shape (*, 3, 3), giving a series of 2D Affine
            transforms for the paths. These encode translations, rotations,
            and scalings in the standard way.
        offsets: array_like
            An array of offsets of shape (N, 2)
        offset_coordinates : string
            the coordinates code for the offsets, which should be either
            'data' for data coordinates, or 'figure' for figure (pixel)
            coordinates.
        offset_order : string
            either "before" or "after". This specifies whether the offset
            is applied before the path transform, or after.  The matplotlib
            backend equivalent is "before"->"data", "after"->"screen".
        styles: dictionary
            A dictionary in which each value is a list of length N, containing
            the style(s) for the paths.
        mplobj : matplotlib object
            the matplotlib plot element which generated this collection
        beforezoffset before transformfigurepoints10,0alphazorder)rZ   rW   r\   	dasharrayr   r   rL   rM   r]   r^   offsetoffset_coordinatesrQ   N)NotImplementedErrorry   r   Affine2D	transformr   export_colorrb   )r   rr   path_coordinatesrs   rt   r   offset_orderru   rQ   tuppathpath_transformr   eclwfcverticesr]   r^   s                      r   draw_path_collectionzRenderer.draw_path_collection   s   f 8##%&?@@@--e_gvVV 	 	C9<6T>62r2"&Hi'0@@N%//99H8++#+ "/33"/33# * E NN,##5     !	 	r   c           
          d         \  }}t          fddD                       }d|d<   |D ]}	|                     |d|||	||           dS )	a  
        Draw a set of markers. By default, this is done by repeatedly
        calling draw_path(), but renderers should generally overload
        this method to provide a more efficient implementation.

        In matplotlib, markers are created using the plt.plot() command.

        Parameters
        ----------
        data : array_like
            A shape (N, 2) array of datapoints.
        coordinates : string
            A string code, which should be either 'data' for data coordinates,
            or 'figure' for figure (pixel) coordinates.
        style : dictionary
            a dictionary specifying the appearance of the markers.
        mplobj : matplotlib object
            the matplotlib plot element which generated this marker collection
        
markerpathc              3   ,   K   | ]}||         fV  d S r   rA   ).0keyr^   s     r   	<genexpr>z(Renderer.draw_markers.<locals>.<genexpr>E  s@       
 
 %*
 
 
 
 
 
r   )r   rZ   rW   r   r\   r~   r   r}   r   N)r`   rb   )
r   rL   rM   r^   rP   rQ   r   r]   rc   vertexs
      `      r   rK   zRenderer.draw_markers0  s    ( $L1) 
 
 
 
Q
 
 
 
 
	 "(	+ 		 		FNN$##.     		 		r   c                     t                      )a  
        Draw text on the image.

        Parameters
        ----------
        text : string
            The text to draw
        position : tuple
            The (x, y) position of the text
        coordinates : string
            A string code, which should be either 'data' for data coordinates,
            or 'figure' for figure (pixel) coordinates.
        style : dictionary
            a dictionary specifying the appearance of the text.
        text_type : string or None
            if specified, a type of text such as "xlabel", "ylabel", "title"
        mplobj : matplotlib object
            the matplotlib plot element which generated this text
        r   )r   textpositionrM   r^   	text_typerQ   s          r   	draw_textzRenderer.draw_textU  s    , "###r   rL   c                     t                      )a  
        Draw a path.

        In matplotlib, paths are created by filled regions, histograms,
        contour plots, patches, etc.

        Parameters
        ----------
        data : array_like
            A shape (N, 2) array of datapoints.
        coordinates : string
            A string code, which should be either 'data' for data coordinates,
            'figure' for figure (pixel) coordinates, or "points" for raw
            point coordinates (useful in conjunction with offsets, below).
        pathcodes : list
            A list of single-character SVG pathcodes associated with the data.
            Path codes are one of ['M', 'm', 'L', 'l', 'Q', 'q', 'T', 't',
                                   'S', 's', 'C', 'c', 'Z', 'z']
            See the SVG specification for details.  Note that some path codes
            consume more than one datapoint (while 'Z' consumes none), so
            in general, the length of the pathcodes list will not be the same
            as that of the data array.
        style : dictionary
            a dictionary specifying the appearance of the line.
        offset : list (optional)
            the (x, y) offset of the path. If not given, no offset will
            be used.
        offset_coordinates : string (optional)
            A string code, which should be either 'data' for data coordinates,
            or 'figure' for figure (pixel) coordinates.
        mplobj : matplotlib object
            the matplotlib plot element which generated this path
        r   )r   rL   rM   r]   r^   r   r   rQ   s           r   rb   zRenderer.draw_pathm  s    V "###r   c                     t                      )aV  
        Draw an image.

        Parameters
        ----------
        imdata : string
            base64 encoded png representation of the image
        extent : list
            the axes extent of the image: [xmin, xmax, ymin, ymax]
        coordinates: string
            A string code, which should be either 'data' for data coordinates,
            or 'figure' for figure (pixel) coordinates.
        style : dictionary
            a dictionary specifying the appearance of the image
        mplobj : matplotlib object
            the matplotlib plot object which generated this image
        r   )r   imdataextentrM   r^   rQ   s         r   
draw_imagezRenderer.draw_image  s    $ "###r   r   )NN)NrL   N)__name__
__module____qualname__staticmethodr   r   r   propertyr    r"   r%   r   r1   r7   r?   r.   r/   r4   r5   r<   r=   rR   rJ   ry   r   rK   r   rb   r   rA   r   r   r	   r	      s7       . . \. O O \O O O \O 2 2 X2 3 3 X3 3 3 X3 	 	 ^	 	 	 ^	     ^   	 	 	  	 	 	  	 	 	 HLM M M M
 
 
 
B ; ; \;L N N N N`# # # #L JN$ $ $ $< !+$ +$ +$ +$Z$ $ $ $ $ $r   r	   )r+   rm   
contextlibr   packaging.versionr   numpyrj   
matplotlibrh   r    r   objectr	   rA   r   r   <module>r      s         % % % % % % % % % % % %         ! ! ! ! ! !      _$ _$ _$ _$ _$v _$ _$ _$ _$ _$r   