From 48dae69cd03475c034c7ad7991d3941f01d61cdd Mon Sep 17 00:00:00 2001 From: joelostblom Date: Mon, 4 Nov 2019 00:48:17 +0100 Subject: [PATCH 1/6] Remove hardcoded grids for marginal plots --- packages/python/plotly/plotly/express/_core.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/python/plotly/plotly/express/_core.py b/packages/python/plotly/plotly/express/_core.py index 3e01f445c26..1047397bbb9 100644 --- a/packages/python/plotly/plotly/express/_core.py +++ b/packages/python/plotly/plotly/express/_core.py @@ -375,16 +375,12 @@ def configure_cartesian_marginal_axes(args, fig, orders): # Configure axis ticks on marginal subplots if args["marginal_x"]: - fig.update_yaxes( - showticklabels=False, showgrid=args["marginal_x"] == "histogram", row=nrows - ) - fig.update_xaxes(showgrid=True, row=nrows) + fig.update_yaxes(showticklabels=False, row=nrows) + fig.update_xaxes(row=nrows) if args["marginal_y"]: - fig.update_xaxes( - showticklabels=False, showgrid=args["marginal_y"] == "histogram", col=ncols - ) - fig.update_yaxes(showgrid=True, col=ncols) + fig.update_xaxes(showticklabels=False, col=ncols) + fig.update_yaxes(col=ncols) # Add axis titles to non-marginal subplots y_title = get_decorated_label(args, args["y"], "y") From b026da271064339fc9db9624bfd402bde1fd70d0 Mon Sep 17 00:00:00 2001 From: joelostblom Date: Mon, 4 Nov 2019 00:48:47 +0100 Subject: [PATCH 2/6] Turn of y-axis line and ticks for marginal 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 1047397bbb9..b6b8e40dd93 100644 --- a/packages/python/plotly/plotly/express/_core.py +++ b/packages/python/plotly/plotly/express/_core.py @@ -375,11 +375,11 @@ def configure_cartesian_marginal_axes(args, fig, orders): # Configure axis ticks on marginal subplots if args["marginal_x"]: - fig.update_yaxes(showticklabels=False, row=nrows) + fig.update_yaxes(showticklabels=False, showline=False, ticks="", row=nrows) fig.update_xaxes(row=nrows) if args["marginal_y"]: - fig.update_xaxes(showticklabels=False, col=ncols) + fig.update_xaxes(showticklabels=False, showline=False, ticks="", col=ncols) fig.update_yaxes(col=ncols) # Add axis titles to non-marginal subplots From de45214082c4d427c956f6477c714f45c7c7193c Mon Sep 17 00:00:00 2001 From: joelostblom Date: Mon, 4 Nov 2019 17:21:29 +0100 Subject: [PATCH 3/6] Add marginal grid lines for templates that don't specify showgrid --- packages/python/plotly/plotly/express/_core.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/python/plotly/plotly/express/_core.py b/packages/python/plotly/plotly/express/_core.py index b6b8e40dd93..635a13fda2f 100644 --- a/packages/python/plotly/plotly/express/_core.py +++ b/packages/python/plotly/plotly/express/_core.py @@ -374,13 +374,27 @@ def configure_cartesian_marginal_axes(args, fig, orders): set_cartesian_axis_opts(args, xaxis, "x", orders) # Configure axis ticks on marginal subplots + # Don't change the marginal grid settings if the template already specifies `showgrid` + if isinstance( + pio.templates[args["template"]].layout.xaxis.showgrid, bool + ) or isinstance(pio.templates[args["template"]].layout.yaxis.showgrid, bool): + grid_set = True + else: + grid_set = False + if args["marginal_x"]: fig.update_yaxes(showticklabels=False, showline=False, ticks="", row=nrows) fig.update_xaxes(row=nrows) + if not grid_set: + fig.update_yaxes(showgrid=args["marginal_x"] == "histogram", row=nrows) + fig.update_xaxes(showgrid=True, row=nrows) if args["marginal_y"]: fig.update_xaxes(showticklabels=False, showline=False, ticks="", col=ncols) fig.update_yaxes(col=ncols) + if not grid_set: + fig.update_xaxes(showgrid=args["marginal_y"] == "histogram", col=ncols) + fig.update_yaxes(showgrid=True, col=ncols) # Add axis titles to non-marginal subplots y_title = get_decorated_label(args, args["y"], "y") From c8625d49f48b668bbbbbb62799958698305fa498 Mon Sep 17 00:00:00 2001 From: joelostblom Date: Tue, 5 Nov 2019 07:28:00 +0100 Subject: [PATCH 4/6] Remove meaningless lines --- packages/python/plotly/plotly/express/_core.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/python/plotly/plotly/express/_core.py b/packages/python/plotly/plotly/express/_core.py index 635a13fda2f..dd382203f2f 100644 --- a/packages/python/plotly/plotly/express/_core.py +++ b/packages/python/plotly/plotly/express/_core.py @@ -384,14 +384,12 @@ def configure_cartesian_marginal_axes(args, fig, orders): if args["marginal_x"]: fig.update_yaxes(showticklabels=False, showline=False, ticks="", row=nrows) - fig.update_xaxes(row=nrows) if not grid_set: fig.update_yaxes(showgrid=args["marginal_x"] == "histogram", row=nrows) fig.update_xaxes(showgrid=True, row=nrows) if args["marginal_y"]: fig.update_xaxes(showticklabels=False, showline=False, ticks="", col=ncols) - fig.update_yaxes(col=ncols) if not grid_set: fig.update_xaxes(showgrid=args["marginal_y"] == "histogram", col=ncols) fig.update_yaxes(showgrid=True, col=ncols) From 2d0a53e84fccf98ecdc62aefb447b7866ad29e13 Mon Sep 17 00:00:00 2001 From: joelostblom Date: Tue, 5 Nov 2019 07:28:34 +0100 Subject: [PATCH 5/6] Clarify by comparing with None instead of bool --- packages/python/plotly/plotly/express/_core.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/python/plotly/plotly/express/_core.py b/packages/python/plotly/plotly/express/_core.py index dd382203f2f..95ff8a63268 100644 --- a/packages/python/plotly/plotly/express/_core.py +++ b/packages/python/plotly/plotly/express/_core.py @@ -375,12 +375,11 @@ def configure_cartesian_marginal_axes(args, fig, orders): # Configure axis ticks on marginal subplots # Don't change the marginal grid settings if the template already specifies `showgrid` - if isinstance( - pio.templates[args["template"]].layout.xaxis.showgrid, bool - ) or isinstance(pio.templates[args["template"]].layout.yaxis.showgrid, bool): - grid_set = True - else: + if (pio.templates[args["template"]].layout.xaxis.showgrid is None + or pio.templates[args["template"]].layout.yaxis.showgrid is None): grid_set = False + else: + grid_set = True if args["marginal_x"]: fig.update_yaxes(showticklabels=False, showline=False, ticks="", row=nrows) From a143c469f3549529c23d66c419ec73f993f8d0c7 Mon Sep 17 00:00:00 2001 From: joelostblom Date: Tue, 5 Nov 2019 07:30:14 +0100 Subject: [PATCH 6/6] Prepare for change in args to hold template instance instead of template string name --- packages/python/plotly/plotly/express/_core.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/python/plotly/plotly/express/_core.py b/packages/python/plotly/plotly/express/_core.py index 95ff8a63268..1c44041f5d3 100644 --- a/packages/python/plotly/plotly/express/_core.py +++ b/packages/python/plotly/plotly/express/_core.py @@ -375,8 +375,10 @@ def configure_cartesian_marginal_axes(args, fig, orders): # Configure axis ticks on marginal subplots # Don't change the marginal grid settings if the template already specifies `showgrid` - if (pio.templates[args["template"]].layout.xaxis.showgrid is None - or pio.templates[args["template"]].layout.yaxis.showgrid is None): + if ( + args["template"].layout.xaxis.showgrid is None + or args["template"].layout.yaxis.showgrid is None + ): grid_set = False else: grid_set = True