
    M/Ph                     0    d dl mZ d dlZddZ	 	 	 ddZdS )    Nfactorc                    t          j                    }|t          |           n|}| }|d|         }|                    d          }|                    t          j        |          |d|         d           |                    d           t          j        |	                                          }|d         |d         z
  }|dt          j        | |g          z  z  }|
                    t          j        |                     |                    |           t          j        |                                          }	d}
|	d         |	d         z
  }|	|
t          j        | |g          z  z  }	|                    |	           |                    d	           |                    d
           |                    |           ||z  }t          j        |          }|                    d          }|                    t          j        |          |d|         d           |                    t          j        |          |d|         d           |                    d           t          j        |	                                          }|d         |d         z
  }|dt          j        | |g          z  z  }|
                    t          j        |                     |                    |           t          j        |                                          }	d}
|	d         |	d         z
  }|	|
t          j        | |g          z  z  }	|                    |	           |                    d           |                    d           |                    |           |                    ddgd           |                                 |S )a
  
    Plot of the ordered eigenvalues and variance explained for the loadings

    Parameters
    ----------
    eigenvals : array_like
        The eigenvalues
    total_var : float
        the total variance (for plotting percent variance explained)
    ncomp : int, optional
        Number of factors to include in the plot.  If None, will
        included the same as the number of maximum possible loadings
    x_label : str
        label of x-axis

    Returns
    -------
    Figure
        Handle to the figure.
    Ny   zb-oT)tight   r   g{Gz?z
Scree Plot
Eigenvaluez   zg--ozVariance Explained
Proportion
Cumulative   )loc)pltfigurelenadd_subplotplotnparange	autoscalearrayget_xlim
set_xticksset_xlimget_ylimset_ylim	set_title
set_ylabel
set_xlabelcumsumlegendtight_layout)	eigenvals	total_varncompx_labelfigvalsaxxlimspylimscaleper_variancecumper_variances                ^/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/statsmodels/multivariate/plots.py
plot_screer0      s\   * *,,C#mC	NNNED<D 
		BGGBIed7U7mU333LLtL8BKKMM""D	a47	BD28bS"I&&&&DMM")E""###KK8BKKMM""DE	a47	BEBHrc2Y''''DKKLLMM,MM')#Li--O			BGGBIel7U73U;;;GGBIeogg6???LLtL8BKKMM""D	a47	BD28bS"I&&&&DMM")E""###KK8BKKMM""DE	a47	BEBHrc2Y''''DKKLL%&&&MM,MM'II|\*I222J    Factor patternsc                 X   | j         \  }}|Ag }t          |          D ]/}t          |dz   |          D ]}	|                    ||	g           0|d t          |          D             }|d t          |          D             }g }
|D ] }|d         }|d         }	t          j        d          }|
                    |           |                    d          }t          | j         d                   D ]0}t          j        | ||f         | ||	f         ||         d	
           1|                    | dd|f         | dd|	f         d           |                    |           |U||          d||         dd}||	          d||	         dd}|	                    |           |
                    |           n6|	                    ||                    |
                    ||	                    d}t          j        | |g          }t          j        | |g          }|                    |ddgd           |                    ddg|d           |                    dd           |                    |           |                    |           |                                 "|
S )a  
    Plot factor loadings in 2-d plots

    Parameters
    ----------
    loadings : array like
        Each column is a component (or factor)
    col_names : a list of strings
        column names of `loadings`
    row_names : a list of strings
        row names of `loadings`
    loading_pairs : None or a list of tuples
        Specify plots. Each tuple (i, j) represent one figure, i and j is
        the loading number for x-axis and y-axis, respectively. If `None`,
        all combinations of the loadings will be plotted.
    percent_variance : array_like
        The percent variance explained by each factor.

    Returns
    -------
    figs : a list of figure handles
    Nr   c                     g | ]}d |z  S )z	factor %d .0is     r/   
<listcomp>z!plot_loadings.<locals>.<listcomp>l   s    >>>[1_>>>r1   c                     g | ]}d |z  S )zvar %dr5   r6   s     r/   r9   z!plot_loadings.<locals>.<listcomp>n   s    888aX\888r1   r   )   r;   )figsizeo      )fontsizeboz (z.1fz%)g?zk--equaldatalim)shaperangeappendr   r   r   textr   r   r   r   r   r   
set_aspectr   r   r!   )loadings	col_names	row_namesloading_pairspercent_variancetitlek_varn_factorr8   jfigsitemr&   r(   kx_stry_strvr)   r+   s                       r/   plot_loadingsrW   L   s   2 nOE8x 	- 	-A1q5** - -$$aV,,,,->>eHoo>>>	885<<888	D  GGj(((C__S!!x~a()) 	0 	0AHXad^Xad^q\B0 0 0 0 0
AA555
U' |BB'7':BBBBE |BB'7':BBBBEMM%   MM%    MM)A,'''MM)A,'''x!Q  x!Q  
q!fe$$$
Ae$$$
gy)))
D
DKr1   )Nr   )NNNNr2   )matplotlib.pyplotpyplotr   numpyr   r0   rW   r5   r1   r/   <module>r[      sk             D D D DN 7;7;)@ @ @ @ @ @r1   