You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tight_layout() doesn't work properly on plots with a WCSAxes projection #8703
A Matpltolib Axes created with projection=wcs does not play well with Matplotlib's tight_layout() method, that is supposed to re-size elements of a figure such that there are no overlapping labels/axes etc.
projection=None, no tight_layout: projection=None, with tight_layout:
(note how this re-organises things nicely) projection='wcs', no tight_layout: projection='wcs', with tight_layout:
Note how things actually get worse!
I don't think so, that is only a problem on Matplotlib dev (post version 3.0.3), whereas this is an issue on a version of Maptlotlib (3.0.3) that predates that change.
Basically the fundamental issue is that get_tightbbox actually requires the figure to be drawn once before it returns correct results. We should probably find a way to avoid this - but in the mean time we could overload tight_layout in WCSAxes and just force a draw first.
As I slowly descend into madness trying to work this out, a note that the end goal to get this working is to have TickLabels and AxisLabels have their own get_tight_bbox() methods that can calculate their own Bboxes. This is going to need a lot of refactoring, but I suspect in the long run it should significantly tidy up the WCSAxes code.
Activity
pllim commentedon May 15, 2019
Is this related to #8678 (comment) ?
dstansby commentedon May 15, 2019
I don't think so, that is only a problem on Matplotlib dev (post version
3.0.3), whereas this is an issue on a version of Maptlotlib (3.0.3) that predates that change.astrofrog commentedon May 15, 2019
I have some ideas :)
astrofrog commentedon May 17, 2019
A workaround for now is to call:
before
Basically the fundamental issue is that
get_tightbboxactually requires the figure to be drawn once before it returns correct results. We should probably find a way to avoid this - but in the mean time we could overloadtight_layoutinWCSAxesand just force a draw first.dstansby commentedon Oct 4, 2020
For reference, some simpler code to reproduce this:
dstansby commentedon Oct 5, 2020
As I slowly descend into madness trying to work this out, a note that the end goal to get this working is to have
TickLabelsandAxisLabelshave their ownget_tight_bbox()methods that can calculate their own Bboxes. This is going to need a lot of refactoring, but I suspect in the long run it should significantly tidy up the WCSAxes code.