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

New button to toolbar for tight_layout. #1023

Closed
wants to merge 1 commit into from

Conversation

WeatherGod
Copy link
Member

  • Need a new icon!

@pelson
Copy link
Member

pelson commented Jul 19, 2012

Is tight_layout togglable? If so, it would be good if this button were.

In terms of adding this to the toolbar, I can see why it is desirable, but I really am not sure adding the additional (slightly strange) behaviour of tight_layout is worth an extra button. Perhaps a (ctrl prefixed) keyboard shortcut might be a better alternative?

@@ -2511,7 +2511,9 @@ class NavigationToolbar2(object):
('Zoom', 'Zoom to rectangle', 'zoom_to_rect', 'zoom'),
(None, None, None, None),
('Subplots', 'Configure subplots', 'subplots', 'configure_subplots'),
('Tight', 'Tighten the layout', 'subplots', 'tight_layout'),
Copy link
Member

Choose a reason for hiding this comment

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

I'm glad my factoring has made it so easy to add a button. I can't remember if there were any backends which do not currently use this list. Probably worth checking.

@WeatherGod
Copy link
Member Author

@pelson tight_layout() is not toggle-able, in a sense, but maybe it could be made to be that way in this context. Try out the following. Make a 4x4 subplot array and display that. Then, press the tight_layout button. You see that the figure adjusted. Now, resize your window to be much smaller. Currently, you have to press the tight_layout button again to trigger a recalculation of the layout.

To make this togglable, one would have to hook into the resize event and have tight_layout called repeatedly as the figure window is resized, and to also save the state of the original subplots adjust parameters. Shouldn't be too difficult there, but it would be smart to make the tight_layout() scripting call be modal much like ion()/ioff().

With respect to whether this deserves another button or not, I am actually inclined to agree with you. For one thing, I am wary of adding yet another button to the toolbar, which may or may not have an impact with users who have long expected only those buttons there and have extended it with their own buttons for their own apps. Second, if we go with a togglable approach, it may make more sense to have this as a checkbox in the subplots_adjust widget. This has the advantage of staying out of the way and not needing a new icon. However, it does make it a little bit harder to discover this functionality.

@efiring
Copy link
Member

efiring commented Jul 22, 2012

This is related to #774.
To make tight_layout less flakey in practice, I think that colorbar needs to have use_gridspec=True as its default.

I certainly don't like adding another button by default, and especially not for something that only sort of works sometimes.

Apart from the change to colorbar to use gridspec, I'm not sure what else tight_layout needs, or what can be done with it. I see that it doesn't work with suptitle. The real problem is that we don't have a full geometry manager, in all its horrible complexity, so something like tight_layout just cannot work well in general.

@pelson
Copy link
Member

pelson commented Jul 22, 2012

The real problem is that we don't have a full geometry manager, in all its horrible complexity, so something like tight_layout just cannot work well in general.

Yes. I have been thinking the same thing for some time. I have actually started playing with implementing such a thing (as a proof of concept, not with actual Axes etc.). My feeling is that tight_layout is a hack to fix a deep rooted problem, and the better approach would be to address the root cause. But all this is getting a little deep for such a small PR. I think I will bring the subject up on the mailing list in the next couple of weeks.

@WeatherGod: I think @efiring share a concern for putting an icon on the toolbar (by default). My preferred approach would be to provide a keyboard binding to provide this functionality, maybe "ctrl+t" (note: there are still some backends which can't do ctrl modifiers yet). Alternatively, I suspect those that use tight_layout use it a lot, having an rc param might be a better approach (as per #774).

@mdboom
Copy link
Member

mdboom commented Aug 3, 2012

@pelson: Want to write a MEP for a full-fledged geometry manager? (Probably incorporating some of the ideas in axes_grid?)

@efiring
Copy link
Member

efiring commented Aug 6, 2012

@WeatherGod, I don't see much support for this PR in its present form. I hope you don't mind my closing it. If you do, then go ahead and re-open it.

@efiring efiring closed this Aug 6, 2012
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.

None yet

4 participants