1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
U
¬ý°d{<ã    @s¾ddlmZddlmZddlmZmZmZddlZddl    m
Z
ddl Z    ddl Z ddlmZddlmZddlmZmZmZerÌdd    lmZdd
lmZdd lmZdd lmZdd l mZddlm Z m!Z!dddœdd„Z"dddœdd„Z#dddœdd„Z$dHdddœdd„Z%dId!d"d#d$d%œd&d'„Z&dJd!dddd#d*œd+d,„Z'd-dd.œd/d0„Z(dd#dd1œd2d3„Z)d4d!d!d!d!dddd5œd6d7„Z*d8d9d:œd;d<„Z+dKd8d=œd>d?„Z,dd@dœdAdB„Z-dCdDdEœdFdG„Z.dS)Lé)Ú annotations)Úceil)Ú TYPE_CHECKINGÚIterableÚSequenceN)Úticker)Úfind_stack_level)Ú is_list_like)Ú ABCDataFrameÚABCIndexÚ    ABCSeries)ÚAxes)ÚAxis)ÚFigure)ÚLine2D)ÚTable)Ú    DataFrameÚSeriesrÚbool)ÚfigÚreturncCst|dƒsdS| ¡ S)z+Whether fig has constrained_layout enabled.Úget_constrained_layoutF)Úhasattrr)r©rúXd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/plotting/_matplotlib/tools.pyÚdo_adjust_figure&s
rÚNonecOst|ƒr|j||ŽdS)zCCall fig.subplots_adjust unless fig has constrained_layout enabled.N)rZsubplots_adjust)rÚargsÚkwargsrrrÚmaybe_adjust_figure-srr )ÚaxrcCs:| ¡D]}| d¡| |¡q| ¡}t|dddS)NÚrightgš™™™™™É?)Úbottom)Úget_xticklabelsZset_haZ set_rotationÚ
get_figurer)r ZrotÚlabelrrrrÚformat_date_labels3s
 
 r&zDataFrame | Seriesr)ÚdatarcKsft|tƒr| ¡}nt|tƒr ntdƒ‚|dkr6|j}|dkrD|j}|j}tj    j    |f|||dœ|—ŽS)Nz&Input data must be DataFrame or Series)ÚcellTextÚ    rowLabelsÚ    colLabels)
Ú
isinstancer Zto_framer
Ú
ValueErrorÚindexÚcolumnsÚvaluesÚ
matplotlibÚtable)r r'r)r*rr(rrrr1<s&
 
 
ÿÿÿr1ÚboxÚintztuple[int, int] | NoneÚstrztuple[int, int])ÚnplotsÚlayoutÚ layout_typercCsx|dk    rÌt|ttfƒr"t|ƒdkr*tdƒ‚|\}}|dkr\|dkr\t||ƒ|f}\}}nF|dkr†|dkr†|t||ƒf}\}}n|dkr¢|dkr¢d}t|ƒ‚|||krÈtd|›d|›d|›ƒ‚|S|d    krØd
S|d krèd |fS|d krø|d fSd
ddddœ}z
||WStk
rrd }|d|kr@|d 7}q&|d ||krb||d fYS||fYSYnXdS)Néz)Layout must be a tuple of (rows, columns)éÿÿÿÿrz1At least one dimension of layout must be positivez
Layout of Úxz# must be larger than required size Zsingle)ér;Z
horizontalr;Zvertical)r;r8)r8r8)r;r8éé)r+ÚtupleÚlistÚlenr,rÚKeyError)r5r6r7ÚnrowsÚncolsÚmsgZlayoutsÚkrrrÚ _get_layoutSs@ ÿ
 rFFT)ÚnaxesÚsharexÚshareyÚsqueezer7cKsddlm}    |dkri}|dkr.|    jf|Ž}
n¼t|ƒr¦|rBt|ƒ}|dk    r\tjdttƒd|sd|rvtjdttƒd|j    |kr–|j
d  ¡}
|
|fSt d|›dƒ‚|  ¡}
|dkrÐ|rÂ|
|fS|
t|ƒfSntjd    ttƒd|
  ¡t|||d
\} } | | } tj| td }|
j| | df|Ž}|r2||d <|r@||d <||d<td| ƒD]F}| ¡}||krxd|d <d|d <|
j| | |df|Ž}|||<qR|| krÂ||d…D]}| d¡q°t|| || | ||ƒ|r| dkrð|d}n| | | ¡ ¡}n | | | ¡}|
|fS)a”    
    Create a figure with a set of subplots already made.
 
    This utility wrapper makes it convenient to create common layouts of
    subplots, including the enclosing figure object, in a single call.
 
    Parameters
    ----------
    naxes : int
      Number of required axes. Exceeded axes are set invisible. Default is
      nrows * ncols.
 
    sharex : bool
      If True, the X axis will be shared amongst all subplots.
 
    sharey : bool
      If True, the Y axis will be shared amongst all subplots.
 
    squeeze : bool
 
      If True, extra dimensions are squeezed out from the returned axis object:
        - if only one subplot is constructed (nrows=ncols=1), the resulting
        single Axis object is returned as a scalar.
        - for Nx1 or 1xN subplots, the returned object is a 1-d numpy object
        array of Axis objects are returned as numpy 1-d arrays.
        - for NxM subplots with N>1 and M>1 are returned as a 2d array.
 
      If False, no squeezing is done: the returned axis object is always
      a 2-d array containing Axis instances, even if it ends up being 1x1.
 
    subplot_kw : dict
      Dict with keywords passed to the add_subplot() call used to create each
      subplots.
 
    ax : Matplotlib axis object, optional
 
    layout : tuple
      Number of rows and columns of the subplot grid.
      If not specified, calculated from naxes and layout_type
 
    layout_type : {'box', 'horizontal', 'vertical'}, default 'box'
      Specify how to layout the subplot grid.
 
    fig_kw : Other keyword arguments to be passed to the figure() call.
        Note that all keywords not recognized above will be
        automatically included here.
 
    Returns
    -------
    fig, ax : tuple
      - fig is the Matplotlib Figure object
      - ax can be either a single axis object or an array of axis objects if
      more than one subplot was created.  The dimensions of the resulting array
      can be controlled with the squeeze keyword, see above.
 
    Examples
    --------
    x = np.linspace(0, 2*np.pi, 400)
    y = np.sin(x**2)
 
    # Just a figure and one subplot
    f, ax = plt.subplots()
    ax.plot(x, y)
    ax.set_title('Simple plot')
 
    # Two subplots, unpack the output array immediately
    f, (ax1, ax2) = plt.subplots(1, 2, sharey=True)
    ax1.plot(x, y)
    ax1.set_title('Sharing Y axis')
    ax2.scatter(x, y)
 
    # Four polar axes
    plt.subplots(2, 2, subplot_kw=dict(polar=True))
    rNz6When passing multiple axes, layout keyword is ignored.)Ú
stacklevelzoWhen passing multiple axes, sharex and sharey are ignored. These settings must be specified when creating axes.z"The number of passed axes must be z, the same as the output plotr;zTTo output multiple subplots, the figure containing the passed axes is being cleared.)r6r7©ZdtyperHrIF)Úmatplotlib.pyplotÚpyplotÚfigurer    Ú flatten_axesÚwarningsÚwarnÚ UserWarningrÚsizeZflatr$r,ÚclearrFÚnpÚemptyÚobjectZ add_subplotÚrangeÚcopyÚ set_visibleÚhandle_shared_axesZreshaperJ)rGrHrIrJZ
subplot_kwr r6r7Zfig_kwÚpltrrBrCr5ÚaxarrZax0ÚiÚkwdsÚaxesrrrÚcreate_subplots…s~U ýü
 
ÿü
 
 
 
 rbr)ÚaxisrcCs€| ¡D]}| d¡qt| ¡tjƒr6| t ¡¡t| ¡tj    ƒrV| 
t  d¡¡|  ¡D]}| d¡q^|  ¡ d¡dS)NFÚ)Zget_majorticklabelsr[r+Zget_minor_locatorrZ NullLocatorZset_minor_locatorZ AutoLocatorZget_minor_formatterZ NullFormatterZset_minor_formatterZFormatStrFormatterZget_minorticklabelsZ    get_label)rcÚtrrrÚ_remove_labels_from_axis=s    rf)Úax1Ú compare_axisrcCsj|dkr| ¡}n|dkr$| ¡}ntdƒ‚| |¡}| ¡ ¡}|D]}t || ¡ ¡¡sFdSqFdS)aA
    Return whether an axis is externally shared.
 
    Parameters
    ----------
    ax1 : matplotlib.axes.Axes
        Axis to query.
    compare_axis : str
        `"x"` or `"y"` according to whether the X-axis or Y-axis is being
        compared.
 
    Returns
    -------
    bool
        `True` if the axis is externally shared. Otherwise `False`.
 
    Notes
    -----
    If two axes with different positions are sharing an axis, they can be
    referred to as *externally* sharing the common axis.
 
    If two axes sharing an axis also have the same position, they can be
    referred to as *internally* sharing the common axis (a.k.a twinning).
 
    _handle_shared_axes() is only interested in axes externally sharing an
    axis, regardless of whether either of the axes is also internally sharing
    with a third axis.
    r:ÚyzD_has_externally_shared_axis() needs 'x' or 'y' as a second parameterTF)Zget_shared_x_axesZget_shared_y_axesr,Z get_siblingsÚ get_positionZ
get_pointsrVZ array_equal)rgrhraZ
ax1_pointsZax2rrrÚ_has_externally_shared_axisMs
 
ÿ
 rkzIterable[Axes])r^r5rGrBrCrHrIrc Cs6|dkr2dd„}dd„}dd„}    |dkròz~tj|d|dftjd}
|D]} |  ¡|
|| ƒ|| ƒf<qL|D]6} |
|| ƒd|| ƒfsŒqn|sšt| dƒrnt| jƒqnWnHtk
rðdd„} |D]&} | | ƒrÒqÄ|sàt| dƒrÄt| jƒqÄYnX|dkr2|D]0} |    | ƒrq|s$t| d    ƒrt| jƒqdS)
Nr;cSs | ¡jjS©N)Úget_subplotspecZrowspanÚstart©r:rrrÚ<lambda>‰óz$handle_shared_axes.<locals>.<lambda>cSs | ¡jjSrl)rmZcolspanrnrorrrrpŠrqcSs | ¡ ¡Srl)rmÚ is_first_colrorrrrpŒrqrLr:cSs | ¡ ¡Srl)rmÚ is_last_rowrorrrrp¢rqri)    rVÚzerosZbool_Z get_visiblerkrfZxaxisÚ
IndexErrorZyaxis) r^r5rGrBrCrHrIZrow_numZcol_numrrr6r rsrrrr\s6    
 
 
r\zAxes | Sequence[Axes]z
np.ndarray)rarcCs<t|ƒst |g¡St|tjtfƒr2t |¡ ¡St |¡Srl)r    rVÚarrayr+Zndarrayr ZasarrayZravel©rarrrrP´s
 rPrwcCs†ddlm}t|ƒD]l}|dk    r2|j| ¡|d|dk    rL|j| ¡|d|dk    rf|j| ¡|d|dk    r|j| ¡|dq|S)Nr)Zfontsize)Zrotation)rMrNrPZsetpr#Zget_yticklabels)raZ
xlabelsizeZxrotZ
ylabelsizeZyrotr]r rrrÚset_ticks_props¼s  rxz list[Line2D]cCs<| ¡}t|dƒr ||j ¡7}t|dƒr8||j ¡7}|S)NÚright_axÚleft_ax)Ú    get_linesrryrz)r ÚlinesrrrÚ get_all_linesÑs 
 
r}zIterable[Line2D]ztuple[float, float])r|rcCsNtjtj }}|D]0}|jdd}tt |¡|ƒ}tt |¡|ƒ}q||fS)NF)Úorig)rVÚinfZ    get_xdataÚminZnanminÚmaxZnanmax)r|Úleftr!Úliner:rrrÚget_xlimÝs  r„)NN)Nr2)FFTNNNr2)NNNN)/Ú
__future__rÚmathrÚtypingrrrrQr0rZmatplotlib.tableÚnumpyrVZpandas.util._exceptionsrZpandas.core.dtypes.commonr    Zpandas.core.dtypes.genericr
r r Zmatplotlib.axesr Zmatplotlib.axisrZmatplotlib.figurerZmatplotlib.linesrrZpandasrrrrr&r1rFrbrfrkr\rPrxr}r„rrrrÚ<module>sZ          
ÿý4ø925
û