Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove marginal plot grids as hardcoded default #1863

Closed
wants to merge 6 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions packages/python/plotly/plotly/express/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,17 +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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here you should check fig.layout.template actually

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, that's not right... you can just check args["template"] directly, at this point it should already be a template object.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, that's not right either! but it should be... I'm going to PR that in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the pio.templates part to be compatible with your upcoming PR. I also changed the comparison to be against None for clarity.

) 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, showgrid=args["marginal_x"] == "histogram", row=nrows
)
fig.update_xaxes(showgrid=True, row=nrows)
fig.update_yaxes(showticklabels=False, showline=False, ticks="", row=nrows)
fig.update_xaxes(row=nrows)
joelostblom marked this conversation as resolved.
Show resolved Hide resolved
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, showgrid=args["marginal_y"] == "histogram", col=ncols
)
fig.update_yaxes(showgrid=True, col=ncols)
fig.update_xaxes(showticklabels=False, showline=False, ticks="", col=ncols)
fig.update_yaxes(col=ncols)
joelostblom marked this conversation as resolved.
Show resolved Hide resolved
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")
Expand Down