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

frameon=False shifts plot axes to to the right and increases figure width #1586

Closed
pmacaodh opened this issue Dec 11, 2012 · 8 comments
Closed

Comments

@pmacaodh
Copy link

The frameon argument shifts the plot axes to the right leaving a strip of blank canvas to the left of the plot axes, while increasing the figure's width. Altogether, a highly undesirable side-effect.

pylab.plot(range(10));
ax=pylab.gca();
ax.legend('test', frameon=False)

I'm using 1.2.0rc3

A search for frameon in issues produced nothing describing this problem. A wider google search uncovered a couple of references to this problem but the solution still eludes me.

@dmcdougall
Copy link
Member

I can't recreate this with the OS X or Qt4Agg backends. I also can't recreate it saving a png from Agg. All this is using master, which is currently at dc1d0ee.

I can't recreate this with OS X or Qt4Agg backends on the current v1.2.x tip, which is currently at da2d0c4.

I also can't recreate this with OS X or Qt4Agg on v1.2.0rc3.

Could you provide a little more information about your backend? And perhaps add a screen shot of the behaviour you are seeing? GitHub now allows you to drag an image into the comment box to attach it.

Thanks for reporting the problem, @pmacaodh.

@pmacaodh
Copy link
Author

I'm using the pylab backend in ipython:

Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)]
IPython 0.14.dev -- An enhanced Interactive Python.

Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].

image

Hope that can help you track it down. Thanks for you efforts!

@jenshnielsen
Copy link
Member

The issue is with bbox_inches='tight which ipython uses in the inline backend.
The bounding box of the legend is only calculated when the frame is on. I have
a pull request fixing this shortly.

@jenshnielsen
Copy link
Member

@pmacaodh Do you have the possibility to test the attached pull request?

@jenshnielsen
Copy link
Member

By the way. This code illustrates the issue: (toggling between True and False

fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.plot(range(10));
ax=pylab.gca();
l = ax.legend('test', frameon=True)
plt.savefig('test.png',bbox_inches='tight')
print l.get_window_extent(fig._cachedRenderer)
print l._legend_box.get_window_extent(fig._cachedRenderer)

@pmacaodh
Copy link
Author

@jenshnielsen I'm afraid I don't have the possibility to test the pull request - I'm not so proficient in these development tools.

Thanks for your efforts. I trust the fix will appear in the main code base soon so I'll hold tight until then.

@tacaswell
Copy link
Member

@jenshnielsen If I am reading this thread correctly you think this if fixed. If I am incorrect please re-open.

@jenshnielsen
Copy link
Member

yes this should be fixed

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 a pull request may close this issue.

4 participants