@@ -1946,7 +1946,7 @@ def test_subplot_titles_shared_axes(self):
1946
1946
layout = Layout (
1947
1947
annotations = Annotations ([
1948
1948
Annotation (
1949
- x = 0.22499999999999998 ,
1949
+ x = 0.225 ,
1950
1950
y = 1.0 ,
1951
1951
xref = 'paper' ,
1952
1952
yref = 'paper' ,
@@ -1957,7 +1957,7 @@ def test_subplot_titles_shared_axes(self):
1957
1957
yanchor = 'bottom'
1958
1958
),
1959
1959
Annotation (
1960
- x = 0.7749999999999999 ,
1960
+ x = 0.775 ,
1961
1961
y = 1.0 ,
1962
1962
xref = 'paper' ,
1963
1963
yref = 'paper' ,
@@ -1968,7 +1968,7 @@ def test_subplot_titles_shared_axes(self):
1968
1968
yanchor = 'bottom'
1969
1969
),
1970
1970
Annotation (
1971
- x = 0.22499999999999998 ,
1971
+ x = 0.225 ,
1972
1972
y = 0.375 ,
1973
1973
xref = 'paper' ,
1974
1974
yref = 'paper' ,
@@ -1979,7 +1979,7 @@ def test_subplot_titles_shared_axes(self):
1979
1979
yanchor = 'bottom'
1980
1980
),
1981
1981
Annotation (
1982
- x = 0.7749999999999999 ,
1982
+ x = 0.775 ,
1983
1983
y = 0.375 ,
1984
1984
xref = 'paper' ,
1985
1985
yref = 'paper' ,
@@ -2010,13 +2010,13 @@ def test_subplot_titles_shared_axes(self):
2010
2010
)
2011
2011
)
2012
2012
)
2013
+
2013
2014
fig = tls .make_subplots (rows = 2 , cols = 2 ,
2014
2015
subplot_titles = ('Title 1' , 'Title 2' ,
2015
2016
'Title 3' , 'Title 4' ),
2016
2017
shared_xaxes = True , shared_yaxes = True )
2017
2018
self .assertEqual (fig .to_plotly_json (), expected .to_plotly_json ())
2018
2019
2019
-
2020
2020
def test_subplot_titles_irregular_layout (self ):
2021
2021
# make a title for each subplot when the layout is irregular:
2022
2022
expected = Figure (
@@ -2155,3 +2155,112 @@ def test_large_columns_no_errors(self):
2155
2155
fig = tls .make_subplots (100 , 1 ,
2156
2156
vertical_spacing = v_space ,
2157
2157
specs = [[{'is_3d' : True }] for _ in range (100 )])
2158
+
2159
+ def test_row_width_and_column_width (self ):
2160
+
2161
+ expected = Figure ({
2162
+ 'data' : [],
2163
+ 'layout' : {'annotations' : [{'font' : {'size' : 16 },
2164
+ 'showarrow' : False ,
2165
+ 'text' : 'Title 1' ,
2166
+ 'x' : 0.405 ,
2167
+ 'xanchor' : 'center' ,
2168
+ 'xref' : 'paper' ,
2169
+ 'y' : 1.0 ,
2170
+ 'yanchor' : 'bottom' ,
2171
+ 'yref' : 'paper' },
2172
+ {'font' : {'size' : 16 },
2173
+ 'showarrow' : False ,
2174
+ 'text' : 'Title 2' ,
2175
+ 'x' : 0.9550000000000001 ,
2176
+ 'xanchor' : 'center' ,
2177
+ 'xref' : 'paper' ,
2178
+ 'y' : 1.0 ,
2179
+ 'yanchor' : 'bottom' ,
2180
+ 'yref' : 'paper' },
2181
+ {'font' : {'size' : 16 },
2182
+ 'showarrow' : False ,
2183
+ 'text' : 'Title 3' ,
2184
+ 'x' : 0.405 ,
2185
+ 'xanchor' : 'center' ,
2186
+ 'xref' : 'paper' ,
2187
+ 'y' : 0.1875 ,
2188
+ 'yanchor' : 'bottom' ,
2189
+ 'yref' : 'paper' },
2190
+ {'font' : {'size' : 16 },
2191
+ 'showarrow' : False ,
2192
+ 'text' : 'Title 4' ,
2193
+ 'x' : 0.9550000000000001 ,
2194
+ 'xanchor' : 'center' ,
2195
+ 'xref' : 'paper' ,
2196
+ 'y' : 0.1875 ,
2197
+ 'yanchor' : 'bottom' ,
2198
+ 'yref' : 'paper' }],
2199
+ 'xaxis' : {'anchor' : 'y' , 'domain' : [0.0 , 0.81 ]},
2200
+ 'xaxis2' : {'anchor' : 'y2' , 'domain' : [0.91 , 1.0 ]},
2201
+ 'xaxis3' : {'anchor' : 'y3' , 'domain' : [0.0 , 0.81 ]},
2202
+ 'xaxis4' : {'anchor' : 'y4' , 'domain' : [0.91 , 1.0 ]},
2203
+ 'yaxis' : {'anchor' : 'x' , 'domain' : [0.4375 , 1.0 ]},
2204
+ 'yaxis2' : {'anchor' : 'x2' , 'domain' : [0.4375 , 1.0 ]},
2205
+ 'yaxis3' : {'anchor' : 'x3' , 'domain' : [0.0 , 0.1875 ]},
2206
+ 'yaxis4' : {'anchor' : 'x4' , 'domain' : [0.0 , 0.1875 ]}}
2207
+ })
2208
+ fig = tls .make_subplots (rows = 2 , cols = 2 ,
2209
+ subplot_titles = ('Title 1' , 'Title 2' , 'Title 3' , 'Title 4' ),
2210
+ row_width = [1 , 3 ], column_width = [9 , 1 ])
2211
+ self .assertEqual (fig .to_plotly_json (), expected .to_plotly_json ())
2212
+
2213
+ def test_row_width_and_shared_yaxes (self ):
2214
+
2215
+ expected = Figure ({
2216
+ 'data' : [],
2217
+ 'layout' : {'annotations' : [{'font' : {'size' : 16 },
2218
+ 'showarrow' : False ,
2219
+ 'text' : 'Title 1' ,
2220
+ 'x' : 0.225 ,
2221
+ 'xanchor' : 'center' ,
2222
+ 'xref' : 'paper' ,
2223
+ 'y' : 1.0 ,
2224
+ 'yanchor' : 'bottom' ,
2225
+ 'yref' : 'paper' },
2226
+ {'font' : {'size' : 16 },
2227
+ 'showarrow' : False ,
2228
+ 'text' : 'Title 2' ,
2229
+ 'x' : 0.775 ,
2230
+ 'xanchor' : 'center' ,
2231
+ 'xref' : 'paper' ,
2232
+ 'y' : 1.0 ,
2233
+ 'yanchor' : 'bottom' ,
2234
+ 'yref' : 'paper' },
2235
+ {'font' : {'size' : 16 },
2236
+ 'showarrow' : False ,
2237
+ 'text' : 'Title 3' ,
2238
+ 'x' : 0.225 ,
2239
+ 'xanchor' : 'center' ,
2240
+ 'xref' : 'paper' ,
2241
+ 'y' : 0.1875 ,
2242
+ 'yanchor' : 'bottom' ,
2243
+ 'yref' : 'paper' },
2244
+ {'font' : {'size' : 16 },
2245
+ 'showarrow' : False ,
2246
+ 'text' : 'Title 4' ,
2247
+ 'x' : 0.775 ,
2248
+ 'xanchor' : 'center' ,
2249
+ 'xref' : 'paper' ,
2250
+ 'y' : 0.1875 ,
2251
+ 'yanchor' : 'bottom' ,
2252
+ 'yref' : 'paper' }],
2253
+ 'xaxis' : {'anchor' : 'y' , 'domain' : [0.0 , 0.45 ]},
2254
+ 'xaxis2' : {'anchor' : 'free' , 'domain' : [0.55 , 1.0 ], 'position' : 0.4375 },
2255
+ 'xaxis3' : {'anchor' : 'y2' , 'domain' : [0.0 , 0.45 ]},
2256
+ 'xaxis4' : {'anchor' : 'free' , 'domain' : [0.55 , 1.0 ], 'position' : 0.0 },
2257
+ 'yaxis' : {'anchor' : 'x' , 'domain' : [0.4375 , 1.0 ]},
2258
+ 'yaxis2' : {'anchor' : 'x3' , 'domain' : [0.0 , 0.1875 ]}}
2259
+ })
2260
+
2261
+ fig = tls .make_subplots (rows = 2 , cols = 2 , row_width = [1 , 3 ], shared_yaxes = True ,
2262
+ subplot_titles = ('Title 1' , 'Title 2' , 'Title 3' , 'Title 4' ))
2263
+
2264
+ self .assertEqual (fig .to_plotly_json (), expected .to_plotly_json ())
2265
+
2266
+ # def test_row_width_and_shared_yaxes(self):
0 commit comments