@@ -776,9 +776,28 @@ def make_subplots(rows=1, cols=1,
776776 column_width (kwarg, list of numbers)
777777 Column_width specifications
778778
779- ex1: column_width = [4, 1, 1, 2] and cols=4
779+ - Functions similarly to `column_width` of `plotly.graph_objs.Table`.
780+ Specify a list that contains numbers where the amount of numbers in
781+ the list is equal to `cols`.
780782
781- Column_width functions similarly to `column_width` of `plotly.graph_objs.Table`
783+ - The numbers in the list indicate the proportions that each column
784+ domains take across the full horizontal domain excluding padding.
785+
786+ - For example, if columns_width=[3, 1], horizontal_spacing=0, and
787+ cols=2, the domains for each column would be [0. 0.75] and [0.75, 1]
788+
789+ row_width (kwargs, list of numbers)
790+ Row_width specifications
791+
792+ - Functions similarly to `column_width`. Specify a list that contains
793+ numbers where the amount of numbers in the list is equal to `rows`.
794+
795+ - The numbers in the list indicate the proportions that each row
796+ domains take along the full vertical domain excluding padding.
797+
798+ - For example, if row_width=[3, 1], vertical_spacing=0, and
799+ cols=2, the domains for each row from top to botton would be
800+ [0. 0.75] and [0.75, 1]
782801 """
783802 # TODO: protected until #282
784803 from plotly .graph_objs import graph_objs
@@ -814,7 +833,8 @@ def make_subplots(rows=1, cols=1,
814833
815834 # Throw exception if non-valid kwarg is sent
816835 VALID_KWARGS = ['horizontal_spacing' , 'vertical_spacing' ,
817- 'specs' , 'insets' , 'subplot_titles' , 'column_width' ]
836+ 'specs' , 'insets' , 'subplot_titles' , 'column_width' ,
837+ 'row_width' ]
818838 for key in kwargs .keys ():
819839 if key not in VALID_KWARGS :
820840 raise Exception ("Invalid keyword argument: '{0}'" .format (key ))
@@ -914,15 +934,13 @@ def _checks(item, defaults):
914934 )
915935 _check_keys_and_fill ('insets' , insets , INSET_defaults )
916936
917- # Set height of each subplot cell (excluding padding)
918- height = (1. - vertical_spacing * (rows - 1 )) / rows
919-
937+ # set heights (with 'column_width')
920938 try :
921939 column_width = kwargs ['column_width' ]
922940 if not isinstance (column_width , list ) or len (column_width ) != cols :
923941 raise Exception (
924942 "Keyword argument 'column_width' must be a list with {} "
925- "numbers in it, the number of subplot columns ." .format (cols )
943+ "numbers in it, the number of subplot cols ." .format (cols )
926944 )
927945 except KeyError :
928946 column_width = None
@@ -937,6 +955,27 @@ def _checks(item, defaults):
937955 else :
938956 widths = [(1. - horizontal_spacing * (cols - 1 )) / cols ] * cols
939957
958+ # set widths (with 'row_width')
959+ try :
960+ row_width = kwargs ['row_width' ]
961+ if not isinstance (row_width , list ) or len (row_width ) != rows :
962+ raise Exception (
963+ "Keyword argument 'row_width' must be a list with {} "
964+ "numbers in it, the number of subplot rows." .format (rows )
965+ )
966+ except KeyError :
967+ row_width = None
968+
969+ if row_width :
970+ cum_sum = float (sum (row_width ))
971+ heights = []
972+ for h in row_width :
973+ heights .append (
974+ (1. - vertical_spacing * (rows - 1 )) * (h / cum_sum )
975+ )
976+ else :
977+ heights = [(1. - vertical_spacing * (rows - 1 )) / rows ] * rows
978+
940979 # Built row/col sequence using 'row_dir' and 'col_dir'
941980 COL_DIR = START_CELL ['col_dir' ]
942981 ROW_DIR = START_CELL ['row_dir' ]
@@ -948,7 +987,7 @@ def _checks(item, defaults):
948987 [
949988 (
950989 (sum (widths [:c ]) + c * horizontal_spacing ),
951- (height + vertical_spacing ) * r
990+ (sum ( heights [: r ]) + r * vertical_spacing )
952991 ) for c in col_seq
953992 ] for r in row_seq
954993 ]
@@ -1076,10 +1115,10 @@ def _add_domain_is_3d(layout, s_label, x_domain, y_domain):
10761115 # Get y domain (dep. on row_dir) using grid & r_spanned
10771116 if ROW_DIR > 0 :
10781117 y_s = grid [r ][c ][1 ] + spec ['b' ]
1079- y_e = grid [r_spanned ][c ][1 ] + height - spec ['t' ]
1118+ y_e = grid [r_spanned ][c ][1 ] + heights [ - 1 - r ] - spec ['t' ]
10801119 else :
10811120 y_s = grid [r_spanned ][c ][1 ] + spec ['b' ]
1082- y_e = grid [r ][c ][1 ] + height - spec ['t' ]
1121+ y_e = grid [r ][c ][1 ] + heights [ - 1 - r ] - spec ['t' ]
10831122 y_domain = [y_s , y_e ]
10841123
10851124 if spec ['is_3d' ]:
@@ -1146,11 +1185,11 @@ def _add_domain_is_3d(layout, s_label, x_domain, y_domain):
11461185 x_domain = [x_s , x_e ]
11471186
11481187 # Get inset y domain using grid
1149- y_s = grid [r ][c ][1 ] + inset ['b' ] * height
1188+ y_s = grid [r ][c ][1 ] + inset ['b' ] * heights [ - 1 - r ]
11501189 if inset ['h' ] == 'to_end' :
1151- y_e = grid [r ][c ][1 ] + height
1190+ y_e = grid [r ][c ][1 ] + heights [ - 1 - r ]
11521191 else :
1153- y_e = y_s + inset ['h' ] * height
1192+ y_e = y_s + inset ['h' ] * heights [ - 1 - r ]
11541193 y_domain = [y_s , y_e ]
11551194
11561195 if inset ['is_3d' ]:
0 commit comments