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
savefig with bbox_inches='tight' ignores annotation without text #3816
Here is test.png, showing that I have two annotations. One annotation, with text, below the axes and one annotation, without text, above the axes.
Here is test-tight.png, showing only one annotation. The annotation above the axes, without the text, has been ignored.
Looking in the source code, bbox_inches='tight' attempts to find the size and location of artists by calling artist.get_window_extent(). When I try arrow1.get_window_extent(), I get a bounding box that appears to correspond to the text. When I try arrow2.get_window_extent(), I get a bounding box with zero height and zero width. Thus, the root of the problem is .get_window_extent() doesn't include the arrow.
Any ideas for how to get around this, in a reasonably robust manner? If I could somehow get the proper bounding box for the whole annotation, then I would be in business. However, I can't even seem to get the line or patch objects out of arrow2.
In case it matters, I am on matplotlib 1.4.0, Python 2.7.6, and Mac OS X 10.8.5
In short, the Annotation class, which sub-classes Text, does not implement the get_window_extent method so when the figure is trying to get the bounds of the contained artists will call the Text.get_window_extent method which has no clue about the arrow or patch_arrow attributes in Annotation.
I was hopping that I could spent some time on it over the next two weeks. The main delay is related to making sure that there are tests checking the basic configurations for the annotation arrow. I can make a in-progress PR if it is desirable.
I was hopping that I could spent some time on it over the next two weeks.
The main delay is related to making sure that there are tests checking the
different configurations for the annotation arrow. I can make a in-progress
PR if it is desirable.
—
Reply to this email directly or view it on GitHub #3816 (comment)
.
This will be tied to #4012 as changing the get_window_extent of the annotation will require that in the setup of the arrow it call up to the Text version of get_window_extent.
Activity
itziakos commentedon Dec 2, 2014
I am halfway through a solution for this issue:
In short, the
Annotationclass, which sub-classesText, does not implement theget_window_extentmethod so when the figure is trying to get the bounds of the contained artists will call theText.get_window_extentmethod which has no clue about thearroworpatch_arrowattributes inAnnotation.tacaswell commentedon Dec 30, 2014
@itziakos Any progress on this?
itziakos commentedon Jan 9, 2015
I was hopping that I could spent some time on it over the next two weeks. The main delay is related to making sure that there are tests checking the basic configurations for the annotation arrow. I can make a in-progress PR if it is desirable.
tacaswell commentedon Jan 9, 2015
Just put 'WIP' in the title so we know it is a 'work in progress'.
It is probably better to get feed back sooner rather than later.
On Thu Jan 08 2015 at 7:29:09 PM Ioannis Tziakos notifications@github.com
wrote:
tacaswell commentedon Jan 19, 2015
This will be tied to #4012 as changing the
get_window_extentof the annotation will require that in the setup of the arrow it call up to theTextversion ofget_window_extent.itziakos commentedon Jan 21, 2015
Work in progress PR #4023
tacaswell commentedon Jan 31, 2015
Should be fixed by 26c7d65