Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb44d047

Browse files
authored
Merge pull request#29324 from meeseeksmachine/auto-backport-of-pr-29258-on-v3.10.x
Backport PR#29258 on branch v3.10.x (Adding font Size as default parameter)
2 parents8f6578e +0e995ce commitb44d047

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

‎lib/matplotlib/table.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,5 +838,9 @@ def table(ax,
838838
ifrowLabelWidth==0:
839839
table.auto_set_column_width(-1)
840840

841+
# set_fontsize is only effective after cells are added
842+
if"fontsize"inkwargs:
843+
table.set_fontsize(kwargs["fontsize"])
844+
841845
ax.add_table(table)
842846
returntable

‎lib/matplotlib/tests/test_table.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,15 @@ def test_table_dataframe(pd):
270270
forr, (index,row)inenumerate(df.iterrows()):
271271
forc,colinenumerate(df.columnsifr==0elserow.values):
272272
asserttable[rifr==0elser+1,c].get_text().get_text()==str(col)
273+
274+
275+
deftest_table_fontsize():
276+
# Test that the passed fontsize propagates to cells
277+
tableData= [['a',1], ['b',2]]
278+
fig,ax=plt.subplots()
279+
test_fontsize=20
280+
t=ax.table(cellText=tableData,loc='top',fontsize=test_fontsize)
281+
cell_fontsize=t[(0,0)].get_fontsize()
282+
assertcell_fontsize==test_fontsize,f"Actual:{test_fontsize},got:{cell_fontsize}"
283+
cell_fontsize=t[(1,1)].get_fontsize()
284+
assertcell_fontsize==test_fontsize,f"Actual:{test_fontsize},got:{cell_fontsize}"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp