File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -838,5 +838,9 @@ def table(ax,
838838        if  rowLabelWidth  ==  0 :
839839            table .auto_set_column_width (- 1 )
840840
841+     # set_fontsize is only effective after cells are added 
842+     if  "fontsize"  in  kwargs :
843+         table .set_fontsize (kwargs ["fontsize" ])
844+ 
841845    ax .add_table (table )
842846    return  table 
Original file line number Diff line number Diff line change @@ -270,3 +270,15 @@ def test_table_dataframe(pd):
270270    for  r , (index , row ) in  enumerate (df .iterrows ()):
271271        for  c , col  in  enumerate (df .columns  if  r  ==  0  else  row .values ):
272272            assert  table [r  if  r  ==  0  else  r + 1 , c ].get_text ().get_text () ==  str (col )
273+ 
274+ 
275+ def  test_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+     assert  cell_fontsize  ==  test_fontsize , f"Actual:{ test_fontsize }  ,got:{ cell_fontsize }  " 
283+     cell_fontsize  =  t [(1 , 1 )].get_fontsize ()
284+     assert  cell_fontsize  ==  test_fontsize , f"Actual:{ test_fontsize }  ,got:{ cell_fontsize }  " 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments