Ë
    úmxiö   ã                  óÐ   — d Z ddlmZ ddlZddlmZmZmZ ddlm	Z	m
Z
 ddlmZ ddlmZmZmZ ddlmZ dd	lmZ erdd
lmZ ddlmZ  G d„ d«      Z	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zy)z/Streamlit support for Matplotlib PyPlot charts.é    )ÚannotationsN)ÚTYPE_CHECKINGÚAnyÚcast)Úmake_deprecated_name_warningÚshow_deprecation_warning)Úmarshall_images)ÚLayoutConfigÚWidthÚvalidate_width)Ú	ImageList)Úgather_metrics)ÚFigure)ÚDeltaGeneratorc                  ó`   — e Zd Z ed«      	 	 ddddœ	 	 	 	 	 	 	 	 	 	 	 dd„«       Zed	d„«       Zy)
ÚPyplotMixinÚpyplotNÚstretch)ÚwidthÚuse_container_widthc          	     ó4  — |�!t        t        ddddd¬«      d¬«       |rdnd	}|st        d
«       t        |d¬«       t        |¬«      }t	        «       }t        | j                  j                  «       ||||fi |¤Ž | j                  j                  d||¬«      S )aÚ  Display a matplotlib.pyplot figure.

        .. Important::
            You must install ``matplotlib>=3.0.0`` to use this command. You can
            install all charting dependencies (except Bokeh) as an extra with
            Streamlit:

            .. code-block:: shell

               pip install streamlit[charts]

        Parameters
        ----------
        fig : Matplotlib Figure
            The Matplotlib ``Figure`` object to render. See
            https://matplotlib.org/stable/gallery/index.html for examples.

            .. note::
                When this argument isn't specified, this function will render the global
                Matplotlib figure object. However, this feature is deprecated and
                will be removed in a later version.

        clear_figure : bool
            If True, the figure will be cleared after being rendered.
            If False, the figure will not be cleared after being rendered.
            If left unspecified, we pick a default based on the value of ``fig``.

            - If ``fig`` is set, defaults to ``False``.

            - If ``fig`` is not set, defaults to ``True``. This simulates Jupyter's
              approach to matplotlib rendering.

        width : "stretch", "content", or int
            The width of the chart element. This can be one of the following:

            - ``"stretch"`` (default): The width of the element matches the
              width of the parent container.
            - ``"content"``: The width of the element matches the
              width of its content, but doesn't exceed the width of the parent
              container.
            - An integer specifying the width in pixels: The element has a
              fixed width. If the specified width is greater than the width of
              the parent container, the width of the element matches the width
              of the parent container.

        use_container_width : bool
            Whether to override the figure's native width with the width of
            the parent container. If ``use_container_width`` is ``True``
            (default), Streamlit sets the width of the figure to match the
            width of the parent container. If ``use_container_width`` is
            ``False``, Streamlit sets the width of the chart to fit its
            contents according to the plotting library, up to the width of the
            parent container.

            .. deprecated::
                ``use_container_width`` is deprecated and will be removed in a
                future release. For ``use_container_width=True``, use
                ``width="stretch"``. For ``use_container_width=False``, use
                ``width="content"``.

        **kwargs : any
            Arguments to pass to Matplotlib's savefig function.

        Example
        -------
        >>> import matplotlib.pyplot as plt
        >>> import streamlit as st
        >>> from numpy.random import default_rng as rng
        >>>
        >>> arr = rng(0).normal(1, 1, size=100)
        >>> fig, ax = plt.subplots()
        >>> ax.hist(arr, bins=20)
        >>>
        >>> st.pyplot(fig)

        .. output::
           https://doc-pyplot.streamlit.app/
           height: 630px

        Matplotlib supports several types of "backends". If you're getting an
        error using Matplotlib with Streamlit, try setting your backend to "TkAgg"::

            echo "backend: TkAgg" >> ~/.matplotlib/matplotlibrc

        For more information, see https://matplotlib.org/faq/usage_faq.html.

        r   r   z
2025-12-31znFor `use_container_width=True`, use `width='stretch'`. For `use_container_width=False`, use `width='content'`.F)Úinclude_st_prefix)Úshow_in_browserr   Úcontenta%  
Calling `st.pyplot()` without providing a figure argument has been deprecated
and will be removed in a later version as it requires the use of Matplotlib's
global figure object, which is not thread-safe.

To future-proof this code, you should pass in a figure as shown below:

```python
fig, ax = plt.subplots()
ax.scatter([1, 2, 3], [1, 2, 3])
# other plotting actions...
st.pyplot(fig)
```

If you have a specific use case that requires this functionality, please let us
know via [issue on Github](https://github.com/streamlit/streamlit/issues).
T)Úallow_content)r   Úimgs)Úlayout_config)	r   r   r   r
   ÚImageListProtoÚmarshallÚdgÚ_get_delta_path_strÚ_enqueue)ÚselfÚfigÚclear_figurer   r   Úkwargsr   Úimage_list_protos           úP/home/htdocs/ttos/venv/lib/python3.12/site-packages/streamlit/elements/pyplot.pyr   zPyplotMixin.pyplot&   s¹   € ðD Ð*Ü$Ü,Ø)ØØ ðNà&+ôð !&õ
ñ "5‘I¸)ˆEáÜ$ð &ô ô$ 	�u¨DÕ1Ü$¨5Ô1ˆä)Ó+ÐÜØ�G‰G×'Ñ'Ó)ØØØØñ	
ð ò	
ð �w‰w×Ñ Ð(8ÈÐÓVÐVó    c                ó   — t        d| «      S )zGet our DeltaGenerator.r   )r   )r#   s    r(   r    zPyplotMixin.dg¸   s   € ô Ð$ dÓ+Ð+r)   )NN)r$   úFigure | Noner%   úbool | Noner   r   r   r,   r&   r   Úreturnr   )r-   r   )Ú__name__Ú
__module__Ú__qualname__r   r   Úpropertyr    © r)   r(   r   r   %   s�   „ Ù�HÓð "Ø$(ðOWð
 !Ø+/ñOWàðOWð "ðOWð
 ðOWð )ðOWð ðOWð 
òOWó ðOWðb ò,ó ñ,r)   r   c           
     óÀ  — 	 dd l m} |j                  «        |s|€d}t	        d|«      }ddddœ}|j                  «       D ��	ci c]  \  }}	||j                  ||	«      “Œ }}}	|j                  |«       t        j                  «       }
 |j                  |
fi |¤Ž t        | |
d ||d	d
d¬«       |r|j                  «        y y # t        $ r t        d«      ‚w xY wc c}	}w )Nr   z$pyplot() command requires matplotlibTr   ÚtightéÈ   Úpng)Úbbox_inchesÚdpiÚformatFÚRGBÚPNG)ÚcoordinatesÚimageÚcaptionr   Ú
proto_imgsÚclampÚchannelsÚoutput_format)Úmatplotlib.pyplotr   ÚioffÚImportErrorr   ÚitemsÚgetÚupdateÚioÚBytesIOÚsavefigr	   Úclf)r<   r'   r   r$   r%   r&   ÚpltÚoptionsÚaÚbr=   s              r(   r   r   ¾   sï   € ðBÝ'à�‰Œ
ñ ØÐØˆLä�8˜SÓ!ˆð
 &¨c¸UÑC€Gð 07¯}©}«×?¡t q¨!ˆq�&—*‘*˜Q Ó"Ñ"Ð?€GÑ?à
‡M�M�'Ôä�J‰J‹L€EØ€C‡K�K�Ñ ˜Ò ÜØØØØ#Ø#ØØØõ	ñ Ø�‰�	ð øôK ò BÜÐ@ÓAÐAðBüó$ @s   ‚C ÁCÃC)NT)r<   Ústrr'   r   r   r
   r$   r+   r%   r,   r&   r   r-   ÚNone)Ú__doc__Ú
__future__r   rI   Útypingr   r   r   Ústreamlit.deprecation_utilr   r   Ú"streamlit.elements.lib.image_utilsr	   Ú#streamlit.elements.lib.layout_utilsr
   r   r   Ústreamlit.proto.Image_pb2r   r   Ústreamlit.runtime.metrics_utilr   Úmatplotlib.figurer   Ústreamlit.delta_generatorr   r   r   r2   r)   r(   ú<module>r]      s‘   ðñ 6å "ã 	ß +Ñ +÷õ ?ß SÑ SÝ AÝ 9áÝ(å8÷V,ñ V,ðz Ø $ð2Øð2à$ð2ð  ð2ð 
ð	2ð
 ð2ð ð2ð 
ô2r)   