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

Add panels as parasite child axes instead of embedding them in the gridspec #46

Closed
wants to merge 2 commits into from

Conversation

lukelbd
Copy link
Collaborator

@lukelbd lukelbd commented Sep 18, 2019

This is a major refactor I am just considering for now. It might make more sense to add axes panels, legends, and colorbars as parasites of the original subplot(s) instead of modifying the underlying subplotspec.

There is some existing similar code for this in the axes_grid1 toolkit. I could borrow this code so that panel, colorbar, and legend long-axis coordinates are automatically updated when subplot positions change.

There are several advantages here.

  • Panels in the same row or column no longer have to be the same width, which can be a problem when you have legends + colorbars alongisde each other.
  • It would be relatively straightforward to implement an axes_grid legend, colorbar, and text methods that draw legends and colorbars or labels along the sides of arbitrary contiguous axes, instead of just along the figure edge.
  • We would no longer have to modify the underlying gridspec when inserting panels. Could delete the cumbersome Figure._insert_rows_columns function.
  • Legends no longer have to belong to an empty, dummy axes -- we can just lock the legend position.
  • Colorbars no longer have to belong to empty, dummy axes to extend them along <100% of the axes -- we just adjust the parent-relative long axis coordinates. This also eliminates all references to GridSpecFromSubplotSpec, which proplot's GridSpec tries to make obsolete.
  • We can now implement rowlabels and collabels with the same API, allow "stacking" arbitrary outer text objects just like colorbars/legends/panels.

The difficulty is that I would have to figure out how to specify axes bounds so that their long axis is locked to another axes (probably similar to the inset_axes locator) and their short axes has locked physical width (i.e. is not in physical units). Also, currently, the tight_layout algorithm works to separate panels and subplots alike by just inspecting axes in adjacent rows/columns of the gridspec. With this PR, an additional step in the algorithm that separates "stacked" objects will have to be written.

This should probably be a v2.0 feature. Really not sure how many people would find it useful/how often someone will run into issues with requiring different panel widths on the same GridSpec row/column. But, I'm leaving this open to discussion.

@lukelbd
Copy link
Collaborator Author

lukelbd commented Nov 6, 2019

This will be implemented in another PR. See #50 for all future updates.

@lukelbd lukelbd closed this Nov 6, 2019
@lukelbd lukelbd reopened this Nov 6, 2019
@bradyrx
Copy link
Collaborator

bradyrx commented Nov 6, 2019

"parasite child axes" sounds spooky

@lukelbd
Copy link
Collaborator Author

lukelbd commented Nov 6, 2019

👻

@lukelbd lukelbd changed the title Implement "panels" as parasite child axes instead Implement panels as parasite child axes instead of embedding them in the gridspec Nov 6, 2019
@lukelbd lukelbd changed the title Implement panels as parasite child axes instead of embedding them in the gridspec Add panels as parasite child axes instead of embedding them in the gridspec Nov 6, 2019
@lukelbd lukelbd added this to the Version 1 milestone Nov 28, 2019
@lukelbd lukelbd closed this Nov 30, 2019
@lukelbd lukelbd deleted the panels-to-parasites branch January 2, 2020 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants