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

Conversation

joelostblom
Copy link
Contributor

I suggest to remove that hardcoded grids for marignal plots and instead inherit the grid settings from the template. This is particularly useful for templates that don't use grids.

The second commit sets two defaults that I think are almost always wanted: No y-axis line or ticks for the marginal plots. I am happy to drop this change with the same logic as above if you think these should be configurable from templates as well.

@joelostblom
Copy link
Contributor Author

The failing test seems unrelated to the changes I made.

@nicolaskruchten
Copy link
Contributor

Can you post a screenshot of some figures with marginals and the default template, given these changes please?

I’m not sure about “always wanted” btw... every explicit setting in PX is there for a reason ;) in this case I found the grid-less marginals with background color pretty ugly, and the bar heights harder to compare, as Weber’s Law would predict.

@joelostblom
Copy link
Contributor Author

Sorry, I didn't mean to imply that the current settings were there for no good reason and I agree that grid lines often facilitates comparisons. I just think the grid lines should be configurable and inherited from the template. So for the default template, there will still be grids in the marginal plots:

image

image

image

But with templates that don't include grids, the marginal plots will not add extra grids:
image

@nicolaskruchten
Copy link
Contributor

Hmm I don’t love the loss of the continuity of grid lines from the main plot...

We could leave the current PX settings alone if you set your new template’s grid lines to white tho!

@nicolaskruchten
Copy link
Contributor

PS the new template looks very slick, looking forward to seeing it in 4.3!

@joelostblom
Copy link
Contributor Author

joelostblom commented Nov 4, 2019

We could leave the current PX settings alone if you set your new template’s grid lines to white tho!

I considered that, but think it would be confusing if someone tried to add grids by setting showgrid=True and the lines would still not be visible because they are white. I can turn off the marginal grids in the template via the secondary and tertiary xy-axes, I am just not sure if that would remove grids from other plots in a unexpected manner. But before I go that route, just one more comment on this PR.

Hmm I don’t love the loss of the continuity of grid lines from the main plot...

Except for histograms, plotly currently only adds gridlines on the y-axis for marginal plots, so although there is continuity from the main plot grid lines, there is still some visual dissonance when looking at a plot like the below since there are square grids only on 2 of 3 plots:

image

I see the value in the xy-grids for the histogram as both axes represent a value and not a grouping as in the rug plots. However, the default for histograms when created as standalone plots is to have only y-grid lines.

image

Although I they are much closer to the x-axis in the standalone plot, it is still easy to see the x-values for the histogram in the marginal plot since the grid lines from the main plot ends just below the histogram and there is little utility in continuing them.

Just some aspects to consider before deciding.

PS the new template looks very slick, looking forward to seeing it in 4.3!

Thank you! =D

@nicolaskruchten
Copy link
Contributor

I think maybe a better fix would probably be to have PX check to see if the active template sets showgrid and not touch it if it does? I don't think the current default template sets this attr.

I doubt that trying to set this in the second/third plots is going to go well template-wise :)

@nicolaskruchten
Copy link
Contributor

PX in general does need to tread more lightly to let templates show through, and I think this sort of "if the template doesn't set it, it's fair game, otherwise no" approach is a good approach... thoughts?

@joelostblom
Copy link
Contributor Author

I like it! I will try that tomorrow, first I am going to get a PR up for the template suggestions so you can have a look.

@joelostblom
Copy link
Contributor Author

@nicolaskruchten Added a commit with your suggested approach.

@@ -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.

@nicolaskruchten
Copy link
Contributor

Thanks for pushing on this! I've rolled these changes into #1875 so I'll close this PR :)

@joelostblom joelostblom mentioned this pull request Nov 7, 2019
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants