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

The figure layout is not respected when plotting inline in the IPython console #6619

Closed
jnsebgosselin opened this issue Mar 6, 2018 · 0 comments

Comments

@jnsebgosselin
Copy link
Member

jnsebgosselin commented Mar 6, 2018

As explained in this StackOverflow answer, the ipython magics are enforcing bbox_inches='tight' by default. This means that the following code :

import matplotlib.pyplot as plt
import numpy as np

plt.close('all')

fig, ax = plt.subplots()
fig.set_size_inches(8,  5)
ax.set_position([0, 0, 1, 1])
ax.plot(np.random.rand(50),  np.random.rand(50))

plt.show()

results in the IPython console when plotting inline as :

>

But, as explicitly specified in my code, what I want is that :

>

This behavior is unacceptable for me when I'm trying to format my figures in a very specific layout for a paper and is the reason why I've never used inline plotting in the past.

To avoid this, one has to override the default magic with :

%config InlineBackend.print_figure_kwargs = {'bbox_inches':None}

As discussed with @ccordoba12, this should be added in the Preferences of the IPython console, under the tab Graphics, in the section Inline backend.

References :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants