Ë
    £�DjF  ã                   ó(   — d Z ddlZddlmZ 	 	 dd„Zy)zE
Bland-Altman mean-difference plots

Author: Joses Ho
License: BSD-3
é    Né   )Úutilsc                 óv  — t        j                  |«      \  }}t        | «      t        |«      k7  rt        d«      ‚|dk  rt        d|› d�«      ‚t	        j
                  | |gd¬«      }| |z
  }	t	        j
                  |	«      }
t	        j                  |	d¬«      }|xs i }d|vrd|d<   |xs i }|xs i }||fD ]  }d|vrd	|d<   d
|vsŒd|d
<   Œ d|vrdd<   d|vrdd<    |j                  ||	fi |¤Ž  |j                  |
fi |¤Ž |j                  dt	        j                  |
d«      › �ddddd¬«       |dkD  r“d|z  |z  }|j                  |
|z
  |
|z   «       ||z  }|
|z
  }|
|z   }t        ||g«      D ]  \  }} |j                  |fi |¤Ž Œ |j                  d|› d|d›�ddddd¬«       |j                  d|› d|d›�dddd¬«       n"|dk(  rd |z  }|j                  |
|z
  |
|z   «       |j                  d!d"¬#«       |j                  d$d"¬#«       |j                  d%¬&«       |j!                  «        |S )'aÞ	  
    Construct a Tukey/Bland-Altman Mean Difference Plot.

    Tukey's Mean Difference Plot (also known as a Bland-Altman plot) is a
    graphical method to analyze the differences between two methods of
    measurement. The mean of the measures is plotted against their difference.

    For more information see
    https://en.wikipedia.org/wiki/Bland-Altman_plot

    Parameters
    ----------
    m1 : array_like
        A 1-d array.
    m2 : array_like
        A 1-d array.
    sd_limit : float
        The limit of agreements expressed in terms of the standard deviation of
        the differences. If `md` is the mean of the differences, and `sd` is
        the standard deviation of those differences, then the limits of
        agreement that will be plotted are md +/- sd_limit * sd.
        The default of 1.96 will produce 95% confidence intervals for the means
        of the differences. If sd_limit = 0, no limits will be plotted, and
        the ylimit of the plot defaults to 3 standard deviations on either
        side of the mean.
    ax : AxesSubplot
        If `ax` is None, then a figure is created. If an axis instance is
        given, the mean difference plot is drawn on the axis.
    scatter_kwds : dict
        Options to to style the scatter plot. Accepts any keywords for the
        matplotlib Axes.scatter plotting method
    mean_line_kwds : dict
        Options to to style the scatter plot. Accepts any keywords for the
        matplotlib Axes.axhline plotting method
    limit_lines_kwds : dict
        Options to to style the scatter plot. Accepts any keywords for the
        matplotlib Axes.axhline plotting method

    Returns
    -------
    Figure
        If `ax` is None, the created figure.  Otherwise the figure to which
        `ax` is connected.

    References
    ----------
    Bland JM, Altman DG (1986). "Statistical methods for assessing agreement
    between two methods of clinical measurement"

    Examples
    --------

    Load relevant libraries.

    >>> import statsmodels.api as sm
    >>> import numpy as np
    >>> import matplotlib.pyplot as plt

    Making a mean difference plot.

    >>> # Seed the random number generator.
    >>> # This ensures that the results below are reproducible.
    >>> np.random.seed(9999)
    >>> m1 = np.random.random(20)
    >>> m2 = np.random.random(20)
    >>> f, ax = plt.subplots(1, figsize = (8,5))
    >>> sm.graphics.mean_diff_plot(m1, m2, ax = ax)
    >>> plt.show()

    .. plot:: plots/graphics-mean_diff_plot.py
    z'm1 does not have the same length as m2.r   z
sd_limit (z) is less than 0.)ÚaxisÚsé   ÚcolorÚgrayÚ	linewidthr   Ú	linestylez--ú:zmean diff:
é   )ç®Gáz®ï?g      à?ÚrightÚcenteré   zaxes fraction)ÚxyÚhorizontalalignmentÚverticalalignmentÚfontsizeÚxycoordsg      ø?ú-z SD: z0.2g)r   gìQ¸…ë±?Úbottomú+)r   gq=
×£pí?)r   r   r   r   é   Ú
Differenceé   )r   ÚMeansé   )Ú	labelsize)r   Úcreate_mpl_axÚlenÚ
ValueErrorÚnpÚmeanÚstdÚscatterÚaxhlineÚannotateÚroundÚset_ylimÚ	enumerateÚ
set_ylabelÚ
set_xlabelÚtick_paramsÚtight_layout)Úm1Úm2Úsd_limitÚaxÚscatter_kwdsÚmean_line_kwdsÚlimit_lines_kwdsÚfigÚmeansÚdiffsÚ	mean_diffÚstd_diffÚkwdsÚ	half_ylimÚlimit_of_agreementÚlowerÚupperÚjÚlims                      úbC:\Crop_Prediction\Backend\crop-ai-system\venv\Lib\site-packages\statsmodels/graphics/agreement.pyÚmean_diff_plotrE      sÌ  € ôR ×!Ñ! "Ó%�G€Cˆä
ˆ2ƒw”#�b“'ÒÜÐBÓCÐCØ�!‚|Ü˜: h ZÐ/@ÐAÓBÐBä�G‰G�R˜�H 1Ô%€EØ�‰G€EÜ—‘˜“€IÜ�v‰v�e !Ô$€HàÒ% 2€LØ
�,ÑØˆ�SÑØ#Ò) r€NØ'Ò-¨2ÐØÐ!1Ð2ò "ˆØ˜$ÑØ"ˆD�‰MØ˜dÒ"Ø !ˆD�Òð	"ð
 ˜.Ñ(Ø ˆˆ[ÑØÐ*Ñ*Øˆˆ[Ñà€B‡J�Jˆu�eÑ,˜|Ò,Ø€B‡J�JˆyÑ+˜NÒ+ð ‡K�K�,œrŸx™x¨	°1Ó5Ð6Ð7ØØ$+Ø"*ØØ(ð ô *ð �!‚|Ø˜8‘^ xÑ/ˆ	Ø
�‰�I 	Ñ)Ø 	Ñ)ô	+à%¨Ñ0ÐØÐ.Ñ.ˆØÐ.Ñ.ˆÜ ¨ Ó/ò 	0‰FˆAˆsØˆB�J‰J�sÑ/Ð.Ó/ð	0à
�‰�a˜�z  u¨T lÐ3Ø#Ø(/Ø&.ØØ,ð 	ô 	.ð 	�‰�a˜�z  u¨T lÐ3Ø#Ø(/ØØ,ð	 	õ 	.ð 
�QŠØ˜‘Lˆ	Ø
�‰�I 	Ñ)Ø 	Ñ)ô	+ð ‡M�M�,¨€MÔ,Ø‡M�M�' B€MÔ'Ø‡N�N˜R€NÔ Ø×ÑÔØ€Jó    )g\�Âõ(\ÿ?NNNN)Ú__doc__Únumpyr$   Ú r   rE   © rF   rD   ú<module>rK      s"   ðñó å ð AEØ9=ôMrF   