Files
intellecton/venv/lib/python3.12/site-packages/matplotlib/__pycache__/table.cpython-312.pyc
T

372 lines
33 KiB
Plaintext
Raw Normal View History

Ë
†Rj`lãóÌdZddlZddlmZmZddlmZmZddl m
Z
ddl m Z ddl
mZdd lmZdd
lmZGd d e
«ZeZGd
de«Zej, dd«Zy)a$
Tables drawing.
.. note::
The table implementation in Matplotlib is lightly maintained. For a more
featureful table implementation, you may wish to try `blume
<https://github.com/swfiua/blume>`_.
Use the factory function `~matplotlib.table.table` to create a ready-made
table from texts. If you need more control, use the `.Table` class and its
methods.
The table consists of a grid of cells, which are indexed by (row, column).
The cell (0, 0) is positioned at the top left.
Thanks to John Gill for providing the class and table.
é)Ú_apiÚ
_docstring)ÚArtistÚallow_rasterization)Ú Rectangle)ÚText)ÚBbox)ÚPath)Ú_is_pandas_dataframecóüeZdZdZdZ dZdedddœZdd d
dd d d
dœˆfd
ZˆfdZˆfdZ dZ
dZ dZ dZ
eˆfd«ZdZdZdZej(d«Zed«Zej0d«ZdZˆxZS)ÚCellzë
A cell is a `.Rectangle` with some associated `.Text`.
As a user, you'll most likely not creates cells yourself. Instead, you
should use either the `~matplotlib.table.table` factory function or
`.Table.add_cell`.
gš™™™™™¹?ÚBRTLÚÚBTÚRL)ÚopenÚclosedÚ
horizontalÚverticalÚwTÚrightNr)Ú edgecolorÚ facecolorÚfillÚtextÚlocÚfontpropertiesÚ
visible_edgesc ó¨t |||||||¬«|jd«|
|_||_t |d|dd|| |d¬«|_y)
Parameters
----------
xy : 2-tuple
The position of the bottom left corner of the cell.
width : float
The cell width.
height : float
The cell height.
edgecolor : :mpltype:`color`, default: 'k'
The color of the cell border.
facecolor : :mpltype:`color`, default: 'w'
The cell facecolor.
fill : bool, default: True
Whether the cell background is filled.
text : str, optional
The cell text.
loc : {'right', 'center', 'left'}
The alignment of the text within the cell.
fontproperties : dict, optional
A dict defining the font properties of the text. Supported keys and
values are the keyword arguments accepted by `.FontProperties`.
visible_edges : {'closed', 'open', 'horizontal', 'vertical'} or substring of 'BRTL'
The cell edges to be drawn with a line: a substring of 'BRTL'
(bottom, right, top, left), or one of 'open' (no edges drawn),
'closed' (all edges drawn), 'horizontal' (bottom and top),
'vertical' (right and left).
)ÚwidthÚheightrrrFrrÚcenter)Úclip_onrrÚhorizontalalignmentÚverticalalignmentN)ÚsuperÚ__init__Ú set_clip_onr Ú_locr Ú_text) ÚselfÚxyr"r#rrrrrrr Ú __class__s €úS/home/antigravity/intellecton/venv/lib/python3.12/site-packages/matplotlib/table.pyr+z
Cell.__init__:sjø€ôN ј 5°¸dØ#,¸ ð ô Cà ×Ñ˜ÔØÔðˆŒ Ü˜B˜q™E R¨¡U°EØ#°NØ.1ÀXôOˆ
ócó2t||«d|_y©NT)r*Ú
set_transformÚstale)r/Útr1s €r2r6zCell.set_transformlsø€Ü
ј àˆ
r3cóZt||«|jj|«y©N)r*Ú
set_figurer.)r/Úfigr1s €r2r;zCell.set_figureqs"ø€Ü
јØ
×ј"r3có|jS)z!Return the cell `.Text` instance.)r.©r/s r2Úget_textz
Cell.get_textus àz‰zÐr3cóH|jj|«d|_y)zSet the text fontsize.TN)r.Ú set_fontsizer7)r/Úsizes r2rAzCell.set_fontsizeysà
×Ñ Ôˆ
r3có6|jj«S)zReturn the cell fontsize.)r.Ú get_fontsizer>s r2rDzCell.get_fontsize~sàz‰z×(r3cóø|j«}|j|«}|dkDrS||j«kDr@|dz}|j|«|j|«}|dkDr||j«kDrŒ@|S)z9Shrink font size until the text fits into the cell width.r)rDÚget_required_widthÚ get_widthrA)r/ÚrendererÚfontsizeÚrequireds r2Úauto_set_font_sizezCell.auto_set_font_sizeszàר×*¨8ÓØ˜Šl˜x¨$¯.©.Ó*:Ò ˜‰Mˆ × Ñ ˜hÔ ×.¨xÓ8ˆ˜Šl˜x¨$¯.©.Ó*:Ó
ˆr3có¬|j«syt| |«|j|«|jj|«d|_y)NF)Ú get_visibler*ÚdrawÚ_set_text_positionr.r7)r/rHr1s €r2rNz Cell.drawsCø€à×ÑÔ ä
 à ×Ñ Ô
˜Ôˆ
r3cóº|j|«}|j|jdz z}|jj «}|dk(r|j
|j dz z}nU|dk(r'|j
|j |jzz}n)|j
|j d|jz
zz}|jj||f«y)z.Set text up so it is drawn in the right place.ér$ÚleftrN) Úget_window_extentÚy0r#r.Úget_horizontalalignmentÚx0r"ÚPADÚ set_position)r/rHÚbboxr&rr%s r2rOzCell._set_text_position˜à×% hÓà G‰Gd—kk A‘oÑ àj‰jר (Š?ؘ$Ÿ*™* q™.Ñ(‰AØ
FŠ]ؘ$Ÿ*™* t§x¡xÑ/‰Aà˜$Ÿ*™*¨¨D¯H©H© Ñ5ˆAØ
×Ñ  A Õ'r3có¢|jj|«j|j«j ««j
S)zY
Return the text bounds as *(x, y, width, height)* in table coordinates.
)r.rSÚ transformedÚget_data_transformÚinvertedÚbounds)r/rHs r2Úget_text_boundszCell.get_text_bounds§s<ð
×,¨XÓ˜T×ð r3cóX|j|«\}}}}|dd|jzzzS)z/Return the minimal required width for the cell.çð?g@)r_rW)r/rHÚbrÚhs r2rFzCell.get_required_width¯s2à×)¨(Ó3‰
ˆˆ1ˆaØC˜3 §¡™>Ñ+r3c óH|jj|«d|_y)zk
Update the text properties.
Valid keyword arguments are:
%(Text:kwdoc)s
TN)r.Ú_internal_updater7)r/Úkwargss r2Úset_text_propszCell.set_text_props´sð
×# ˆ
r3có|jS)a"
The cell edges to be drawn with a line.
Reading this property returns a substring of 'BRTL' (bottom, right,
top, left').
When setting this property, you can use a substring of 'BRTL' or one
of {'open', 'closed', 'horizontal', 'vertical'}.
)Ú_visible_edgesr>s r2r zCell.visible_edgesÀsð×"r3c óp|j_d_y|jvrj|_d_ytˆfd|D««rNt dj |dj
j«dj
j«««|_d_y)Nc3ó:K|]}|jvŒy­wr:©Ú_edges©Ú.0Úedger/s €r2ú <genexpr>z%Cell.visible_edges.<locals>.<genexpr>Ôsøèø€Ò=¨t4˜tŸ{™{Ô=ùsƒz=Invalid edge param {}, must only be one of {} or string of {}z, T)rnrjÚ
_edge_aliasesÚanyÚ
ValueErrorÚformatÚjoinr7©r/Úvalues` r2r zCell.visible_edgesÍø€à ˆ=Ø"&§+¡+ˆ ðˆ
ðd×
(Ø"&×"4Ñ"4°UÑ";ˆ ðˆ
ôÓ=°uÔ ð"6ß6<±fØ%*Ø%)§Y¡Y¨t×/AÑ/AÓ%BØ%)§Y¡Y¨t¯{©{Ó%;ó7=ó
#(ˆ ؈
r3cóøtjg}|jˆfdjD««tj|ddvrtj|d<tddgddgddgddgddgg|d¬«S) z*Return a `.Path` for the `.visible_edges`.c3ózK|]2}|jvrtjntjŒ4y­wr:)rjr ÚLINETOÚMOVETOros €r2rrz Cell.get_path.<locals>.<genexpr>às3øèø€òð  4×#6Ñ#6Ñ6ŒDKŠK¼D¿K¹KÓ %ùsƒ8;rNéÿÿÿÿçraT)Úreadonly)r r}ÚextendrnÚ CLOSEPOLY)r/Úcodess` r2Úget_pathz
Cell.get_pathÝsø€ä
ˆØ
óŸ ô ;‰;˜e A B˜ ŸˆE"‰IÜØ3ˆZ˜#˜s˜ c¨3 Z°#°s°¸cÀ3¸ZÐ Øôð r3)Ú__name__Ú
__module__Ú __qualname__Ú__doc__rWrnrsr+r6r;r?rArDrKrrNrOr_rFrÚinterpdrhÚpropertyr Úsetterr„Ú
__classcell__©r1s@r2rr'ø„ñð €CØ
€FØ%'Ø%+Ø%)Ø%)ñ€Mð¨#ØØØØ $Ø
0Oôdô
òò
 ðóóðò
ò
×Ññ óð ðñ
ð
×Ññ
óð
ö r3rcóVeZdZdZidddddddd “d
d d d
ddddddddddddddddddd d!“d"d#“d$d%i¥Z dZd&Z d=ˆfd'„ Zd(„Zd)„Z d*„Z
e d+„«Z e jd,„«Z d-„Zed.„«Zd/„Zd0„Zd1„Zd>d2„Zd3„Zd4„Zd5„Zd?d6„Zd7„Zd8„Zd9„Zd:„Zd;„Zd<„ZˆxZS)@ÚTableaD
A table of cells.
The table consists of a grid of cells, which are indexed by (row, column).
For a simple table, you'll have a full grid of cells with indices from
(0, 0) to (num_rows-1, num_cols-1), in which the cell (0, 0) is positioned
at the top left. However, you can also add cells with negative indices.
You don't have to add a cell to every grid position, so you can create
tables that have holes.
*Note*: You'll usually not create an empty table from scratch. Instead use
`~matplotlib.table.table` to create a table from data.
Úbestrz upper rightrz
upper leftrQz
lower leftéz lower rightéz center leftéz center rightéz lower centeréz upper centerér$é z top righté
ztop lefté z bottom lefté z bottom righté
rérRéÚtopéÚbottomég{®Gáz”?c ó"t|«t|t«rQ||jvr4t dj
|dj|j«««|j|}|j|jd¬««||_
||_ ||_ |j«|j|j«i|_d|_g|_d|_|j)|«|j+d«y)a(
Parameters
----------
ax : `~matplotlib.axes.Axes`
The `~.axes.Axes` to plot the table into.
loc : str, optional
The position of the cell with respect to *ax*. This must be one of
the `~.Table.codes`.
bbox : `.Bbox` or [xmin, ymin, width, height], optional
A bounding box to draw the table into. If this is not *None*, this
overrides *loc*.
Other Parameters
----------------
**kwargs
`.Artist` properties.
z3Unrecognized location {!r}. Valid locations are
{}z
ÚrootNT)r*r+Ú
isinstanceÚstrrƒrurvrwr;Ú
get_figureÚ_axesr-Ú_bboxÚ_unstale_viewLimr6Ú transAxesÚ_cellsrnÚ _autoColumnsÚ
_autoFontsizerfr,)r/ÚaxrrYrgr1s €r2r+zTable.__init__ø€ô& ÑÔä cœ3Ô Ø˜$Ÿ*™*Ñ Ø‘V˜C §¡¨T¯Z©ZÓ!8Ó—*‘*˜S‘/ˆCØ ˜Ÿ
¨5˜
ÓˆŒ
؈Œ ؈Œ
ð ×ÑÔØ ×ј2Ÿ<™<ÔˆŒ ؈Œ ØˆÔØÔØ ×јfÔ ×јÕr3cóNd}t|g|¢­d|ji|¤Ž}||||f<|S)aV
Create a cell and add it to the table.
Parameters
----------
row : int
Row index.
col : int
Column index.
*args, **kwargs
All other parameters are passed on to `Cell`.
Returns
-------
`.Cell`
The created cell.
)rrr )rÚedges)r/ÚrowÚcolÚargsrgr0Úcells r2Úadd_cellzTable.add_cellDs8ð&ˆÜB°4ÒB d§j¡jÐB¸6ÑØˆˆS#ˆX‰Øˆ r3có\tjt|¬« |d|d}}|j |j
d¬««|j|j««|jd«||j||f<d|_ y#t$r}t d«|d}~wwxYw) z8
Set a custom cell in a given position.
)rrz0Only tuples length 2 are accepted as coordinatesNFr£T) rÚcheck_isinstancerÚ ExceptionÚKeyErrorr;r6Ú
get_transformr,r7)r/ÚpositionrµÚerrs r2Ú __setitem__zTable.__setitem__\ô
×Ñœd¨Õ ‘{ H¨Q¡Kˆ
˜Ÿ¨U˜Ó ×ј4× ×Ñ˜ÔØ $ˆ ؈
øôòð*Ø/2ð
3ûð 3ús
BÂ B+Â B&Â&B+có |j|S)z-Retrieve a custom cell from a given position.©)r/s r2Ú __getitem__zTable.__getitem__lsà{‰{˜$r3có|jS)a
The default value of `~.Cell.visible_edges` for newly added
cells using `.add_cell`.
Notes
-----
This setting does currently only affect newly created cells using
`.add_cell`.
To change existing cells, you have to set their edges explicitly::
for c in tab.get_celld().values():
c.visible_edges = 'horizontal'
rmr>s r2z Table.edgespsð"{‰{Ðr3có ||_d|_yr5)rnr7rxs r2z Table.edgesƒsàˆŒ ؈
r3có¢|jdz |jd¬«jz|jjj
z dzS)NgR@Tr£g333333ó?)ÚFONTSIZEr§Údpir¨rYr#r>s r2Ú_approx_text_heightzTable._approx_text_heightˆsGØ
 Ñ$ ¡¸D Ó'A×'EÑ'EÑ
×'Ø),ñ .r3cóˆ|€ |jd¬«j«}| td«|j«sy|j d|j «¬«|j
|«t|j«D] }|j|j|«Œ"|jd«d|_ y)NTr£zNo renderer definedÚtable)ÚgidF) Ú
_get_rendererÚ RuntimeErrorrMÚ
open_groupÚget_gidÚ_update_positionsÚsortedr¬rNÚ close_groupr7)r/rHÚkeys r2rNz
Table.drawŒð РبDÓAˆHØ Ð ÜÐ ×ÑÔ Ø×јG¨¯©«ÐÔ ×јxÔ˜$Ÿ+™+Ó ,ˆ K‰K˜Ñ × ! (Õ  ×јWÔˆ
r3có(|jj«Dcgc]#\\}}}|dk\r|dk\r|j|«Œ%}}}}tj|«}|j |j
«j««Scc}}}w)z…
Get a bbox, in axes coordinates for the cells.
Only include those in the range (0, 0) to (maxRow, maxCol).
r)ÚitemsrSr
Úunionr[r])r/rHÚboxesrYs r2Ú_get_grid_bboxzTable._get_grid_bbox¢sð*.¯©×):Ñ):Ó)<÷%Zc˜3 Ø˜1H ¨¢ð×Õ+ˆòz‰z˜%Ó ˆØ×Ñ × 2Ñ 2Ó 4× =Ñ =Ó ?Ó@ùô +sŸ(B
có”|j|«rdifS|jd¬«j«}|‡|jj «Dcgc]#\\}}}|dk\r|dk\r|j |«Œ%}}}}t
j|«}|j|j|j«ifSdifScc}}}w)NFTr£r) Ú_different_canvasr§rSr
Úcontainsr%r&)r/Ú
mouseeventrHrYs r2zTable.contains®à × ! *Ô ˜" ð—?=ˆØ Ð à-1¯[©[×->Ñ->Ó-@÷)™˜#˜s Tؘqš S¨A¢Xð×+¨HÕ/ˆEò—:‘:˜eÓ$ˆDØ—=‘= §¡¨z¯|©|Ó<¸ ˜" ùô
/sÁ(CcóHt|jj««S)z*Return the Artists contained by the table.)Úlistr¬Úvaluesr>s r2Ú get_childrenzTable.get_children¾säD—KK×)r3có|€ |jd¬«j«}|j|«|jj «Dcgc]}|j |«Œ}}t
j|«Scc}w)NTr£)rSr
)r/rHs r2rSzTable.get_window_extentÂsxà РبDÓAˆHØ ×јxÔ!Ÿ[™[×ð×Õ3ˆðz‰z˜%Ó Ð ùò3sÁA?có4i}i}|jj«D]f\\}}}|j|d«}t||j ««||<|j|d«}t||j ««||<Œhd}i} t
|«D]}|| |<|||z
}Œd}
i} t
|d¬«D]}|
| |<|
||z
}
Œ|jj«D]0\\}}}|j| |«|j| |«Œ2y)zV
Calculate row heights and column widths; position cells accordingly.
rrT)ÚreverseN) r¬Ú
setdefaultÚmaxÚ
get_heightrGÚset_xÚset_y) r/ÚwidthsÚheightsr²r#r"ÚxposÚleftsÚyposÚbottomss r2Ú_do_cell_alignmentzTable._do_cell_alignmentËs;ð
ˆØˆØ $§ ¡ × 1Ñ 1Ó 3ò ‰JˆS#˜Ø×¨SÓ1ˆ˜v ¡Ó'8Ó9ˆGC‰LØ×% c¨3Ó/ˆ˜e T§^¡^Ó%5Ó6ˆF3ŠKð ˆØˆÜ˜&“>ò ˆˆE#‰JØ F˜3‘KÑ ‰Dð ðˆØˆÜ˜'¨4Ô !ˆˆGC‰LØ G˜C ‰Dð
!%§ ¡ × 1Ñ 1Ó 3ò ‰JˆS#˜Ø J‰Ju˜S J‰Jw˜s  %r3cóòtj|«}tj|jtj«s t d«|D]}|j j|«Œd|_y)
Automatically set the widths of given columns to optimal sizes.
Parameters
----------
col : int or sequence of ints
The indices of the columns to auto-scale.
z'col must be an int or sequence of ints.TN) ÚnpÚ
atleast_1dÚ
issubdtypeÚdtypeÚintegerÚ TypeErrorr­Úappendr7)r/Úcol1drµs r2Úauto_set_column_widthzTable.auto_set_column_widthês`ô
˜"ˆÜ}‰}˜UŸ[™[¬"¯*©*ÔÐ ò +ˆDØ × Ñ × $ TÕ ˆ
r3cóØ|jj«Dcgc]\}}|d|k(sŒ|Œ}}}tˆfd|D«d¬«}|D]}|j|«Œycc}}w)z#Automatically set width for column.rc3ó@K|]}|j«Œy­wr:)rF)rprHs €r2rrz/Table._auto_set_column_width.<locals>.<genexpr>þsøèø€ÒM¸t˜××Mùsƒr)ÚdefaultN)Ú set_width)r/rHÚcellsÚ max_widths ` r2Ú_auto_set_column_widthzTable._auto_set_column_widthûsgø€à'+§{¡{×'8Ñ'8Ó':×L™)˜#˜t¸cÀ!¹fÈ»m’ÐÑÓMÀuÔMØ !ô#ˆ àò &ˆ N‰N˜  &ùóMs
ŸA&°A&có ||_d|_y)zAutomatically set font size.TN)r7rxs r2rKzTable.auto_set_font_sizesà"ˆÔ؈
r3cóÒt|j«dk(rytt|jj «««j «}g}|jj
«D]E\}}|d|jvrŒ|j|«}t||«}|j|«ŒG|jj «D]}|j|«Œy)Nrr) Úlenr¬ÚnextÚiterrÞrDr­rKÚminrörA)r/rHrIrBs r2Ú_auto_set_font_sizezTable._auto_set_font_sizeä ˆt{‰{Ó ˜qÒ Ø Üœ˜TŸ[™[רˆØŸ× ‰IˆCà1‰v˜×Ø×*¨8Ó4ˆDܘ8 TÓ*ˆHØ L‰L˜Õ ð
 ð—KK× (ˆ × Ñ ˜  (r3cóÊ|jj«D]F}|j|j«|z«|j |j «|z«ŒHy)z<Scale column widths by *xscale* and row heights by *yscale*.N)rGÚ
set_heightrå)r/ÚxscaleÚyscaleÚcs r2Úscalez Table.scalesLà× 2ˆAØ
K‰K˜Ÿ
¨Ñ
L‰L˜Ÿ¨&Ñ  2r3cór|jj«D]}|j|«Œd|_y)a>
Set the font size, in points, of the cell text.
Parameters
----------
size : float
Notes
-----
As long as auto font size has not been disabled, the value will be
clipped such that the text fits horizontally into the cell.
You can disable this behavior using `.auto_set_font_size`.
>>> the_table.auto_set_font_size(False)
>>> the_table.set_fontsize(20)
However, there is no automatic scaling of the row height so that the
text may exceed the cell boundary.
TN)rAr7)r/rBs r2rAzTable.set_fontsize s5ð*—KK× $ˆ × Ñ ˜dÕ ˆ
r3cóÒ|jj«D]J}|j«|j«}}|j ||z«|j ||z«ŒLy)z-Move all the artists by ox, oy (axes coords).N)Úget_xÚget_yræ)r/ÚoxÚoyr r%r&s r2Ú_offsetz
Table._offset9sQà× ˆAØ—7‘7“9˜aŸg™g›iˆqˆAØ
G‰GA˜FŒOØ
G‰GA˜F r3cóê|jD]}|j||«Œ|jr|j|«|j «|j |«}|j \}}}}|j{t|jt«r|jj \}} }
} n|j\}} }
} |j|
|z | |z «||z
} | |z
}
|j «nhtt|j««\}}}}}}}}}}}}}}}}}}d|dz z
|z
} d|dz z
|z
}
|j|||fvr|j|z
} |j|||||fvrd||z|jzz
} |j||||fvrd||z|jzz
}
|j|||fvr|j|z
}
|j|||fvr d|dz z
|z
} |j|||fvr d|dz z
|z
}
|j|||fvr||z } |j|||fvrd|z
} |j|||fvrd|z
}
|j|||fvr||z }
|j!| |
«y)Ngà?rQrra)r­rÿrr×r^r
r Úrangerr-ÚAXESPADr) r/rHrYrbrcrrdÚrlÚrbÚrwÚrhrrÚBESTÚURÚULÚLLÚLRÚCLÚCRÚLCÚUCÚTRÚTLÚBLÚBRÚBs r2zTable._update_positions@ð
× 7ˆ × ¨XÕ  × Ò Ø × $ XÔ 
×ÑÔ×" ,ˆØ—[[‰
ˆˆ1ˆaà :‰:Ð ˜$Ÿ*™*¤dÔ+Ø!%§¡×!2Ñ!2‘™Bà!%§¡˜BØ J‰Jr˜Av˜r A™vÔ aˆaˆ × ,1´°T·Z±Z³Ó+Añ
)ˆT2r˜2˜r 2 r¨2¨r°1Ø
˜Q  1 ˜˜A™Ñ"ˆBؘ˜A™+ Ñ"ˆy‰y˜R  R˜—\\ %Øy‰y˜T 2 r¨1¨bИ!˜a™% $§,¡,Ñ/Øy‰y˜T 2 r¨2И!˜a™% $§,¡,Ñ/Øy‰y˜R  R˜—\\ %Øy‰y˜R  Q˜˜A ™Ek &Øy‰y˜R  Q˜˜A ™Ek &ày‰y˜R  Q˜˜A™YØy‰y˜R  Q˜˜1WØy‰y˜R  Q˜˜1WØy‰y˜R  Q˜˜A™Yà Õr3có|jS)a
Return a dict of cells in the table mapping *(row, column)* to
`.Cell`\s.
Notes
-----
You can also directly index into the Table object to access individual
cells::
cell = table[row, col]
r>s r2Ú get_celldzTable.get_celldzsð{‰{Ðr3)NNr:)T) r…r†r‡rˆrr+rrrNr×rSrÿrKrr rArr.rs@r2rrïs•ø„ñ
ð
ˆV
Ø
˜
à
˜
ð˜
ð˜
ð
˜ 
ð ˜

ð˜
ð˜
ð˜
ð˜
ð˜
ð˜
ð˜
ð˜