-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Join bbox_extra_artists and bbox_inches #1420
Conversation
…tist. Rather join the two bboxes
Great job, @jenshnielsen. |
This looks fine to merge IMHO. Is there an easy test we could put in to catch this for the future? |
I will look into making a test for the bbox stuff later today. I don't think an image comparison test makes much sense but we should be able to make a test of the size of the bbox_union of something like that. |
This is a bug introduced in 2f11dee and only present on master. I'm not sure |
…lipping the table if bbox_inches='tight' is used.
… bbox_extra_artists. The get_window_extent is a method on the cells not the key of the cells.
I have added a test of bbox_inches='tight'. To do this I adapted the image comparison decorator to take a dict that is then passed to the savefig method, this should also make it possible to pass other arguments to the savefig function i.e. dpi or transparent. I'm not sure this is the best solution so if anyone have any better idea I will be happy to adopt it. The test make a figure with a table and and external legend and should verify that the clipping is right and prevent both the issue in #1420 and #1425 from popping up again. In addition I have merged #1421 into this one to clip the table correctly. Furthermore I cherry-picked #1425 into this one. That should be merged from 1.2.x rather than this one. |
There is something wrong with the tests right now. When running all tests these bbox tests are intermixed with the |
For public record, this also fixes another symptom I recently started seeing, where the bbox is totally wrong on any figure with a legend: plt.plot([1,3,2])
plt.legend(["line"])
plt.gcf().savefig('fig.png', bbox_inches='tight') gives this with master (4e6b2c0): and behaves exactly as expected after applying this patch. |
It should be working now. A stupid indention bug in the test caused the problem with the axes test. |
Is there a way to see more verbose output from travis? It is difficult to see if new tests are actually being run by travis |
import numpy as np | ||
|
||
@image_comparison(baseline_images = ['bbox_inches_tight'], remove_text=True, | ||
freetype_version = '2.4.10', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it critical that you have this version of freetype? What happens if you don't specify this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets try to remove it. It the test fails for any one we can add it back in or remove some of the text.
The only approach I know of would be to change the |
Another user reported this on the IPython mailing list http://mail.scipy.org/pipermail/ipython-dev/2012-October/010519.html It would be good if we can get the fix in soon. If needed the test can wait. Is there anything else that needs to be done? |
Can we please soon merge the fix for this issue. In total we now have 2 issue reports from IPython, 1 from matplotlib and a question on the IPython mailing list all about this one simple issue. |
I can confirm that it works as advertised. Thanks a bunch @jenshnielsen. |
👍 I'd be happy to merge this onto master. I will leave it a couple of days for others to comment, nut IMHO this is good to go. Thanks @jenshnielsen |
Would it be possible to merge 1.2.x onto master again soon so this one does not need to carry 77d965d |
Have done. I don't quite follow how it would cause any problems (if they are one and the same commit). As it stands, this PR would merge without a problem. Cheers, |
Thanks. God to know that it is not an issue. Guess I was just underestimating the capacity of git. |
Just pushed a small update. We don't need the if statement if savefig_kwarg defaults to a empty dict instead of none. |
I see your point. I think it's save but there is no reason to risk any issues so lets do it like this. It should be similar to the other default arguments. |
@dmcdougall Yes that's what I did in 6d585f3 and what was done before 63733aa the only difference now compared to the original is that instead of using an if else statement to do calls with different arguments to savefig, savefig_kwarg is now set to an empty dict inside the function if it is None when called. This is similar to how extensions are handled and more readable imho. |
I don't think that commit was merged into 1.2.x . That line is different in 1.2.x and the pull request #1345 only merged into master |
Ah, your right. Its funny how you have to see the pull request to see which branch the commit was applied to. Thanks @jenshnielsen . |
Join bbox_extra_artists and bbox_inches
Good stuff @jenshnielsen : Thanks for your hard work and patience! Cheers, |
Don't ignore the initial bbox when using bbox_extra_artist. Rather join the two bboxes. This should fix #1419