@@ -121,3 +121,43 @@ def test_customcell():
121121 cell = CustomCell ((0 , 0 ), visible_edges = t , width = 1 , height = 1 )
122122 code = tuple (s for _ , s in cell .get_path ().iter_segments ())
123123 assert_equal (c , code )
124+
125+ @image_comparison (baseline_images = ['table_auto_column' ],
126+ extensions = ['png' ])
127+ def test_auto_column ():
128+ fig = plt .figure ()
129+
130+ #iteratble list input
131+ ax1 = fig .add_subplot (3 , 1 , 1 )
132+ ax1 .axis ('off' )
133+ tb1 = ax1 .table (cellText = [['Fit Text' , 2 ],['Longer text than default' , 1 ]],
134+ rowLabels = ["A" ,"B" ],
135+ colLabels = ["Col1" ,"Col2" ],
136+ loc = "center" )
137+ tb1 .auto_set_font_size (False )
138+ tb1 .set_fontsize (12 )
139+ tb1 .auto_set_column_width ([- 1 ,0 ,1 ])
140+
141+ #iteratble tuple input
142+ ax2 = fig .add_subplot (3 , 1 , 2 )
143+ ax2 .axis ('off' )
144+ tb2 = ax2 .table (cellText = [['Fit Text' , 2 ],['Longer text than default' , 1 ]],
145+ rowLabels = ["A" ,"B" ],
146+ colLabels = ["Col1" ,"Col2" ],
147+ loc = "center" )
148+ tb2 .auto_set_font_size (False )
149+ tb2 .set_fontsize (12 )
150+ tb2 .auto_set_column_width ((- 1 ,0 ,1 ))
151+
152+ #3 single input
153+ ax3 = fig .add_subplot (3 , 1 , 3 )
154+ ax3 .axis ('off' )
155+ tb3 = ax3 .table (cellText = [['Fit Text' , 2 ],['Longer text than default' , 1 ]],
156+ rowLabels = ["A" ,"B" ],
157+ colLabels = ["Col1" ,"Col2" ],
158+ loc = "center" )
159+ tb3 .auto_set_font_size (False )
160+ tb3 .set_fontsize (12 )
161+ tb3 .auto_set_column_width (- 1 )
162+ tb3 .auto_set_column_width (0 )
163+ tb3 .auto_set_column_width (1 )
0 commit comments