@@ -1216,46 +1216,6 @@ def infer_config(args, constructor, trace_patch, layout_patch):
1216
1216
if constructor in [go .Treemap , go .Sunburst ] and args ["path" ] is not None :
1217
1217
args = process_dataframe_hierarchy (args )
1218
1218
1219
- if "orientation" in args :
1220
- has_x = args ["x" ] is not None
1221
- has_y = args ["y" ] is not None
1222
- if args ["orientation" ] is None :
1223
- if constructor in [go .Histogram , go .Scatter ]:
1224
- if has_y and not has_x :
1225
- args ["orientation" ] = "h"
1226
- elif constructor in [go .Violin , go .Box , go .Bar , go .Funnel ]:
1227
- if has_x and not has_y :
1228
- args ["orientation" ] = "h"
1229
-
1230
- if args ["orientation" ] is None and has_x and has_y :
1231
- x_is_continuous = _is_continuous (args ["data_frame" ], args ["x" ])
1232
- y_is_continuous = _is_continuous (args ["data_frame" ], args ["y" ])
1233
- if x_is_continuous and not y_is_continuous :
1234
- args ["orientation" ] = "h"
1235
- if y_is_continuous and not x_is_continuous :
1236
- args ["orientation" ] = "v"
1237
-
1238
- if args ["orientation" ] is None :
1239
- args ["orientation" ] = "v"
1240
-
1241
- if constructor == go .Histogram :
1242
- orientation = args ["orientation" ]
1243
- nbins = args ["nbins" ]
1244
- trace_patch ["nbinsx" ] = nbins if orientation == "v" else None
1245
- trace_patch ["nbinsy" ] = None if orientation == "v" else nbins
1246
- trace_patch ["bingroup" ] = "x" if orientation == "v" else "y"
1247
- trace_patch ["orientation" ] = args ["orientation" ]
1248
-
1249
- if constructor in [go .Violin , go .Box ]:
1250
- mode = "boxmode" if constructor == go .Box else "violinmode"
1251
- if layout_patch [mode ] is None and args ["color" ] is not None :
1252
- if args ["y" ] == args ["color" ] and args ["orientation" ] == "h" :
1253
- layout_patch [mode ] = "overlay"
1254
- elif args ["x" ] == args ["color" ] and args ["orientation" ] == "v" :
1255
- layout_patch [mode ] = "overlay"
1256
- if layout_patch [mode ] is None :
1257
- layout_patch [mode ] = "group"
1258
-
1259
1219
attrs = [k for k in attrables if k in args ]
1260
1220
grouped_attrs = []
1261
1221
@@ -1309,8 +1269,45 @@ def infer_config(args, constructor, trace_patch, layout_patch):
1309
1269
if "symbol" in args :
1310
1270
grouped_attrs .append ("marker.symbol" )
1311
1271
1312
- # Compute final trace patch
1313
- trace_patch = trace_patch .copy ()
1272
+ if "orientation" in args :
1273
+ has_x = args ["x" ] is not None
1274
+ has_y = args ["y" ] is not None
1275
+ if args ["orientation" ] is None :
1276
+ if constructor in [go .Histogram , go .Scatter ]:
1277
+ if has_y and not has_x :
1278
+ args ["orientation" ] = "h"
1279
+ elif constructor in [go .Violin , go .Box , go .Bar , go .Funnel ]:
1280
+ if has_x and not has_y :
1281
+ args ["orientation" ] = "h"
1282
+
1283
+ if args ["orientation" ] is None and has_x and has_y :
1284
+ x_is_continuous = _is_continuous (args ["data_frame" ], args ["x" ])
1285
+ y_is_continuous = _is_continuous (args ["data_frame" ], args ["y" ])
1286
+ if x_is_continuous and not y_is_continuous :
1287
+ args ["orientation" ] = "h"
1288
+ if y_is_continuous and not x_is_continuous :
1289
+ args ["orientation" ] = "v"
1290
+
1291
+ if args ["orientation" ] is None :
1292
+ args ["orientation" ] = "v"
1293
+
1294
+ if constructor == go .Histogram :
1295
+ orientation = args ["orientation" ]
1296
+ nbins = args ["nbins" ]
1297
+ trace_patch ["nbinsx" ] = nbins if orientation == "v" else None
1298
+ trace_patch ["nbinsy" ] = None if orientation == "v" else nbins
1299
+ trace_patch ["bingroup" ] = "x" if orientation == "v" else "y"
1300
+ trace_patch ["orientation" ] = args ["orientation" ]
1301
+
1302
+ if constructor in [go .Violin , go .Box ]:
1303
+ mode = "boxmode" if constructor == go .Box else "violinmode"
1304
+ if layout_patch [mode ] is None and args ["color" ] is not None :
1305
+ if args ["y" ] == args ["color" ] and args ["orientation" ] == "h" :
1306
+ layout_patch [mode ] = "overlay"
1307
+ elif args ["x" ] == args ["color" ] and args ["orientation" ] == "v" :
1308
+ layout_patch [mode ] = "overlay"
1309
+ if layout_patch [mode ] is None :
1310
+ layout_patch [mode ] = "group"
1314
1311
1315
1312
if constructor in [go .Histogram2d , go .Densitymapbox ]:
1316
1313
show_colorbar = True
@@ -1358,7 +1355,7 @@ def infer_config(args, constructor, trace_patch, layout_patch):
1358
1355
1359
1356
# Create trace specs
1360
1357
trace_specs = make_trace_spec (args , constructor , attrs , trace_patch )
1361
- return args , trace_specs , grouped_mappings , sizeref , show_colorbar
1358
+ return trace_specs , grouped_mappings , sizeref , show_colorbar
1362
1359
1363
1360
1364
1361
def get_orderings (args , grouper , grouped ):
@@ -1402,10 +1399,12 @@ def get_orderings(args, grouper, grouped):
1402
1399
return orders , group_names , group_values
1403
1400
1404
1401
1405
- def make_figure (args , constructor , trace_patch = {}, layout_patch = {}):
1402
+ def make_figure (args , constructor , trace_patch = None , layout_patch = None ):
1403
+ trace_patch = trace_patch or {}
1404
+ layout_patch = layout_patch or {}
1406
1405
apply_default_cascade (args )
1407
1406
1408
- args , trace_specs , grouped_mappings , sizeref , show_colorbar = infer_config (
1407
+ trace_specs , grouped_mappings , sizeref , show_colorbar = infer_config (
1409
1408
args , constructor , trace_patch , layout_patch
1410
1409
)
1411
1410
grouper = [x .grouper or one_group for x in grouped_mappings ] or [one_group ]
0 commit comments