From ad87b3dae4ac6f7469b2bf1b1a60cf66b996cff7 Mon Sep 17 00:00:00 2001 From: joelostblom Date: Mon, 4 Nov 2019 00:30:24 +0100 Subject: [PATCH 1/4] Even out spacing between marginal x and y plots --- packages/python/plotly/plotly/express/_core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/python/plotly/plotly/express/_core.py b/packages/python/plotly/plotly/express/_core.py index 1b5aee6e0f4..94f977ab7ef 100644 --- a/packages/python/plotly/plotly/express/_core.py +++ b/packages/python/plotly/plotly/express/_core.py @@ -1330,7 +1330,7 @@ def init_figure(args, subplot_type, frame_list, nrows, ncols, col_labels, row_la main_size = 0.84 row_heights = [main_size] * (nrows - 1) + [1 - main_size] - vertical_spacing = 0.01 + vertical_spacing = 0.012 elif args.get("facet_col_wrap", 0): vertical_spacing = 0.07 else: @@ -1343,7 +1343,7 @@ def init_figure(args, subplot_type, frame_list, nrows, ncols, col_labels, row_la main_size = 0.84 column_widths = [main_size] * (ncols - 1) + [1 - main_size] - horizontal_spacing = 0.005 + horizontal_spacing = 0.01 else: horizontal_spacing = 0.02 else: From 2e3ed306baa77aa8194e67ca88bead6ee5be7b3d Mon Sep 17 00:00:00 2001 From: joelostblom Date: Mon, 4 Nov 2019 02:56:16 +0100 Subject: [PATCH 2/4] Take figure size into account when setting marginal spacing --- packages/python/plotly/plotly/express/_core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/python/plotly/plotly/express/_core.py b/packages/python/plotly/plotly/express/_core.py index 94f977ab7ef..b59ddb91fb6 100644 --- a/packages/python/plotly/plotly/express/_core.py +++ b/packages/python/plotly/plotly/express/_core.py @@ -1330,7 +1330,7 @@ def init_figure(args, subplot_type, frame_list, nrows, ncols, col_labels, row_la main_size = 0.84 row_heights = [main_size] * (nrows - 1) + [1 - main_size] - vertical_spacing = 0.012 + vertical_spacing = 0.012 * 600 / args['height'] elif args.get("facet_col_wrap", 0): vertical_spacing = 0.07 else: @@ -1343,7 +1343,7 @@ def init_figure(args, subplot_type, frame_list, nrows, ncols, col_labels, row_la main_size = 0.84 column_widths = [main_size] * (ncols - 1) + [1 - main_size] - horizontal_spacing = 0.01 + horizontal_spacing = 0.012 * 600 / args['width'] else: horizontal_spacing = 0.02 else: From 18ef78f9aded058eae4b445d6d2e2b0dd6d8e63b Mon Sep 17 00:00:00 2001 From: joelostblom Date: Wed, 6 Nov 2019 18:16:46 +0100 Subject: [PATCH 3/4] Blacken single quotes to double --- packages/python/plotly/plotly/express/_core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/python/plotly/plotly/express/_core.py b/packages/python/plotly/plotly/express/_core.py index b59ddb91fb6..284e75ab65e 100644 --- a/packages/python/plotly/plotly/express/_core.py +++ b/packages/python/plotly/plotly/express/_core.py @@ -1330,7 +1330,7 @@ def init_figure(args, subplot_type, frame_list, nrows, ncols, col_labels, row_la main_size = 0.84 row_heights = [main_size] * (nrows - 1) + [1 - main_size] - vertical_spacing = 0.012 * 600 / args['height'] + vertical_spacing = 0.012 * 600 / args["height"] elif args.get("facet_col_wrap", 0): vertical_spacing = 0.07 else: @@ -1343,7 +1343,7 @@ def init_figure(args, subplot_type, frame_list, nrows, ncols, col_labels, row_la main_size = 0.84 column_widths = [main_size] * (ncols - 1) + [1 - main_size] - horizontal_spacing = 0.012 * 600 / args['width'] + horizontal_spacing = 0.012 * 600 / args["width"] else: horizontal_spacing = 0.02 else: From 3af5b47d2201526767be1c221940130b2872b6d1 Mon Sep 17 00:00:00 2001 From: joelostblom Date: Wed, 6 Nov 2019 18:34:42 +0100 Subject: [PATCH 4/4] Do not adjust spacing width on figures that autoscale --- packages/python/plotly/plotly/express/_core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/python/plotly/plotly/express/_core.py b/packages/python/plotly/plotly/express/_core.py index 284e75ab65e..4ccfa063d84 100644 --- a/packages/python/plotly/plotly/express/_core.py +++ b/packages/python/plotly/plotly/express/_core.py @@ -1343,7 +1343,8 @@ def init_figure(args, subplot_type, frame_list, nrows, ncols, col_labels, row_la main_size = 0.84 column_widths = [main_size] * (ncols - 1) + [1 - main_size] - horizontal_spacing = 0.012 * 600 / args["width"] + width_adjustment = 1 if args["width"] is None else 600 / args["width"] + horizontal_spacing = 0.012 * width_adjustment else: horizontal_spacing = 0.02 else: