Ë
    £�Dj¢  ã                   óD   — d Z ddlZddlmZ ddlmZ dgZd	d„Z	 	 	 d
d„Z	y)a¯  create scatterplot with confidence ellipsis

Author: Josef Perktold
License: BSD-3

TODO: update script to use sharex, sharey, and visible=False
    see https://www.scipy.org/Cookbook/Matplotlib/Multiple_Subplots_with_One_Axis_Label
    for sharex I need to have the ax of the last_row when editing the earlier
    rows. Or you axes_grid1, imagegrid
    http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html
é    N)Ústatsé   )ÚutilsÚscatter_ellipsec           	      ó.  — ddl m} t        j                  j	                  |«      \  }}|d   t        j                  j                  |d   «      z  }t        j                  |d   |d   z  «      }	d|	z  t        j                  z  }	dt        j                  |t        j                  j                  |d«      z  «      z  } || dd |d   |d   d|	z   d|d¬	«      }
|
j                  |j                  «       |
j                  d
«       |j                  |
«       y)z%Support function for scatter_ellipse.r   )ÚEllipser   é´   é   NÚnoneg      ø?)ÚangleÚ	facecolorÚ	edgecolorÚlwç      à?)Úmatplotlib.patchesr   ÚnpÚlinalgÚeighÚnormÚarctanÚpiÚsqrtr   Úchi2ÚppfÚset_clip_boxÚbboxÚ	set_alphaÚ
add_artist)ÚmeanÚcovÚaxÚlevelÚcolorr   ÚvÚwÚur   Úells              úcC:\Crop_Prediction\Backend\crop-ai-system\venv\Lib\site-packages\statsmodels/graphics/plot_grids.pyÚ_make_ellipser)      så   € å*ä�9‰9�>‰>˜#Ó�D€A€qØ	ˆ!‰Œr�y‰y�~‰~˜a ™dÓ#Ñ#€AÜ�I‰I�a˜‘d˜1˜Q™4‘iÓ €EØ�%‰Kœ"Ÿ%™%Ñ€EØ	ŒB�G‰G�AœŸ
™
Ÿ™ u¨aÓ0Ñ0Ó1Ñ1€AÙ
�$�r˜�(˜A˜a™D ! A¡$¨c°E©kÀVØ!àô€Cð ×Ñ�R—W‘WÔØ‡M�M�#ÔØ‡M�M�#Õó    c           
      óŽ  — t        j                  |«      }ddlm} t	        j
                  | «      } | j                  d   }	|€t        |	«      D �
cg c]  }
d|
z  ‘Œ	 }}
t        dddd¬	«      }|r|j                  |«       t        d¬
«      }|r|j                  |«       | j                  d«      }t	        j                  | d¬«      }t        d|	«      D �]È  }
d}t        |
«      D �]´  }|j                  |	dz
  |	dz
  |
dz
  |	dz
  z  |z   dz   «      }|j                  d«      }|j                  j                  |«       |j                   j                  |«       t	        j"                  ||
g«      } |j$                  | dd…|f   j&                  i |¤Ž t	        j(                  |«      r|g}|D ]!  }t+        ||   ||dd…df   |f   |fd|i|¤Ž Œ# |r|j-                  ||
   › d||   › �«       |j/                  «       j1                  «       s?|s|j3                  g «       n?|j                  j5                  |j7                  d«      «       n|j9                  ||
   «       |j/                  «       j;                  «       r|j=                  ||   «       n>|s|j?                  g «       n*|j                   j5                  |j7                  d«      «       t	        j@                  | d¬«      }||dd…df   |f   }|jC                  «       }|jE                  «       }|d   d|d   |d   z
  z  z   }|d   dk  s|d   dk  r ||   d   |kD  r|d   d|d   |d   z
  z  z   }n|d   d|d   |d   z
  z  z
  }|d   d|d   |d   z
  z  z   }|jG                  ||d|d   z  «       �Œ· �ŒË |jH                  D ]“  }|j/                  «       j;                  «       r*|j                   j5                  |j7                  d«      «       |j/                  «       j1                  «       sŒj|j                  j5                  |j7                  d«      «       Œ• |S c c}
w )aÈ  Create a grid of scatter plots with confidence ellipses.

    ell_kwds, plot_kdes not used yet

    looks ok with 5 or 6 variables, too crowded with 8, too empty with 1

    Parameters
    ----------
    data : array_like
        Input data.
    level : scalar, optional
        Default is 0.9.
    varnames : list[str], optional
        Variable names.  Used for y-axis labels, and if `add_titles` is True
        also for titles.  If not given, integers 1..data.shape[1] are used.
    ell_kwds : dict, optional
        UNUSED
    plot_kwds : dict, optional
        UNUSED
    add_titles : bool, optional
        Whether or not to add titles to each subplot.  Default is False.
        Titles are constructed from `varnames`.
    keep_ticks : bool, optional
        If False (default), remove all axis ticks.
    fig : Figure, optional
        If given, this figure is simply returned.  Otherwise a new figure is
        created.

    Returns
    -------
    Figure
        If `fig` is None, the created figure.  Otherwise `fig` itself.

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

    >>> from statsmodels.graphics.plot_grids import scatter_ellipse
    >>> data = sm.datasets.statecrime.load_pandas().data
    >>> fig = plt.figure(figsize=(8,8))
    >>> scatter_ellipse(data, varnames=data.columns, fig=fig)
    >>> plt.show()

    .. plot:: plots/graphics_plot_grids_scatter_ellipse.py
    r   Nr   zvar%dr   ú.Úkr   )ÚlsÚmarkerr#   Úalpha)r#   )Úrowvarz% 3.1fr"   ú-é   gš™™™™™Ù?)r   r   g      Ð¿g      Ð?gš™™™™™¹?gš™™™™™É?z$\rho=%0.2f$)%r   Úcreate_mpl_figÚmatplotlib.tickerÚtickerr   Ú
asanyarrayÚshapeÚrangeÚdictÚupdater   r    Úadd_subplotÚFormatStrFormatterÚyaxisÚset_major_formatterÚxaxisÚarrayÚplotÚTÚisscalarr)   Ú	set_titleÚget_subplotspecÚis_first_colÚ
set_yticksÚset_major_locatorÚMaxNLocatorÚ
set_ylabelÚis_last_rowÚ
set_xlabelÚ
set_xticksÚcorrcoefÚget_xlimÚget_ylimÚtextÚaxes)Údatar"   ÚvarnamesÚell_kwdsÚ	plot_kwdsÚ
add_titlesÚ
keep_ticksÚfigÚmtickerÚnvarsÚiÚ
plot_kwds_Ú	ell_kwds_ÚdmeanÚdcovÚax_lastÚjr!   Ú	formatterÚidxr0   ÚdcorrÚdcÚxlimÚylimÚyrangeqÚytÚxts                               r(   r   r   (   s  € ôd ×
Ñ
˜sÓ
#€CÝ'ä�=‰=˜Ó€DØ�J‰J�q‰M€EØÐä).¨u«Ö6 A�G˜a“KÐ6ˆÐ6ä˜¨°3¸cÔB€JÙØ×Ñ˜)Ô$ä˜#Œ€IÙØ×Ñ˜Ô"à�I‰I�a‹L€EÜ�6‰6�$˜qÔ!€Dä�1�e‹_ó ;6ˆàˆÜ�q“ó 8	6ˆAà—‘  q¡¨%°©'°A°a±C¸%À¹'±?À1Ñ3DÀQÑ3FÓGˆBð  ×2Ñ2°8Ó<ˆIØ�H‰H×(Ñ(¨Ô3Ø�H‰H×(Ñ(¨Ô3ä—(‘(˜A˜a˜5“/ˆCØˆB�G‰G�Tš!˜C˜%‘[—]‘]Ð1 jÒ1ä�{‰{˜5Ô!Ø˜�Øò &�Ü˜e C™j¨$¨s²1°T°6©{¸CÐ/?Ñ*@À"ñ &ÈEð &Ø$ó&ð&ñ Ø—‘ ¨¡˜}¨A¨h°q©k¨]Ð;Ô<Ø×%Ñ%Ó'×4Ñ4Ô6Ù!Ø—M‘M "Õ%à—H‘H×.Ñ.¨w×/BÑ/BÀ1Ó/EÕFà—‘˜h q™kÔ*Ø×!Ñ!Ó#×/Ñ/Ô1Ø—‘˜h q™kÕ*á!Ø—M‘M "Õ%à—H‘H×.Ñ.¨w×/BÑ/BÀ1Ó/EÔFä—K‘K ¨QÔ/ˆEØ�sš1˜T˜6‘{ CÐ'Ñ(ˆBØ—;‘;“=ˆDØ—;‘;“=ˆDð ˜1‘g  t¨A¡w°°a±Ñ'8Ñ 9Ñ9ˆGØ�#‰w˜Š 2 c¡7¨T¢>°e¸C±jÀ±mÀgÒ6MØ˜!‘W˜s d¨1¡g°°Q±Ñ&7Ñ8Ñ8‘à˜!‘W˜s d¨1¡g°°Q±Ñ&7Ñ8Ñ8�Ø�a‘˜3 $ q¡'¨D°©GÑ"3Ñ4Ñ4ˆBØ�G‰G�B˜˜O¨R°©WÑ4Ö5òq8	6ð;6ðz �h‰hò ?ˆØ×ÑÓ×+Ñ+Ô-Ø�H‰H×&Ñ& w×':Ñ':¸1Ó'=Ô>Ø×ÑÓ×,Ñ,Õ.Ø�H‰H×&Ñ& w×':Ñ':¸1Ó'=Õ>ð	?ð €Jùòa 7s   ÁQ)gffffffî?N)gÍÌÌÌÌÌì?NNNFFN)
Ú__doc__Únumpyr   Úscipyr   Ú r   Ú__all__r)   r   © r*   r(   ú<module>rs      s4   ðñ
ó Ý å àÐ
€óð$ >BØAFØôIr*   