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

Automatically remove unused subplots #2125

Closed
alexcjohnson opened this issue Oct 26, 2017 · 2 comments · Fixed by #2227
Closed

Automatically remove unused subplots #2125

alexcjohnson opened this issue Oct 26, 2017 · 2 comments · Fixed by #2227
Assignees
Labels
bug something broken
Milestone

Comments

@alexcjohnson
Copy link
Collaborator

This is largely an issue with the plotly workspace, but I imagine other applications can run into it as well:

If you change trace types between different subplots, for example from heatmap to surface, bar to pie, it's possible to end up with an empty subplot (cartesian in those cases, but could be others) that nevertheless exists in layout, with automatically-entered attributes like range and autorange but possibly with explicitly-provided attributes as well. At present we still display these subplots, even though they're useless.

The proposal (discussed offline with @etpinard and @bpostlethwaite) is:

  • Only show subplots that are referenced by some object - be it a trace, shape, annotation, or image.
  • Even hidden objects (visibility: (false|'legendonly')) count as a subplot reference. So a subplot that's blank just because you turned off all the traces on it from the legend, that will still render.
  • If there are no subplots left after we axe all of these, make a blank cartesian subplot so it's not just blank.
  • Do not delete the unused axis and subplot objects from layout, in case the user changes back to the original type, so they don't lose the configuration they did there.

In principle this could be regarded as a breaking change, but in practice it seems like the only thing it breaks is useless plots. If anyone has examples otherwise though I'd love to hear about it!

@rreusser
Copy link
Contributor

You probably know this @alexcjohnson, but I had to work through it. Here's the minimal example where it's apparent:

Plotly.plot('graph', [{
  type: 'pie',
  values: [1]
}], {
  xaxis: {},
  yaxis: {}
})

xaxis and yaxis must both be specified for the axis to show up. I missed that at first.

@etpinard
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants