Skip to content

ImageGrid bug when using inline backend #12370

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

Closed
ezatterin opened this issue Oct 2, 2018 · 5 comments
Closed

ImageGrid bug when using inline backend #12370

ezatterin opened this issue Oct 2, 2018 · 5 comments

Comments

@ezatterin
Copy link

ezatterin commented Oct 2, 2018

Bug report

Bug summary

The ImageGrid class seems to not behave correctly since the upgrade to matplotlib 3.0.0 when the inline backend is used in a Jupyter notebook: the resulting subplots fail to arrange in a grid and are placed on top of eachother. The correct behaviour is reproduced if using the notebook or ipympl backends. Thanks!

Code for reproduction

import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import ImageGrid
import numpy as np

im = np.arange(100)
im.shape = 10, 10

fig = plt.figure(1, (4., 4.))
grid = ImageGrid(fig, 111,  
                 nrows_ncols=(2, 2),  
                 axes_pad=0.1,  
                 )

for i in range(4):
    grid[i].imshow(im)  
    grid[i].set_title('test {0}{0}'.format(i)) 

plt.show()

Actual outcome
image

Expected outcome

image

Matplotlib version

  • Operating system: Debian 9
  • Matplotlib version: 3.0.0
  • Matplotlib backend: inline
  • Python version: 3.5.3
  • Jupyter version (if applicable): 4.4.0
  • Other libraries:
@jklymak
Copy link
Member

jklymak commented Oct 2, 2018

Yeah this seems to be a duplicate of #12355; inline uses bbox_inches='tight', and there was a bad interaction with axes_grid1 subclasses and that saving option. #12363 should fix this as well....

@jklymak
Copy link
Member

jklymak commented Oct 2, 2018

Just add fig.savefig('Boo.png', bbox_inches='tight') to the above to make it reproducible w/o a notebook. #12363 indeed fixes this...

@jklymak
Copy link
Member

jklymak commented Oct 2, 2018

Thanks for the bug report - closing as a duplicate, but I used your example as a new test...

@ezatterin
Copy link
Author

Just add fig.savefig('Boo.png', bbox_inches='tight') to the above to make it reproducible w/o a notebook. #12363 indeed fixes this...

Understood. Thanks to you!

@ImportanceOfBeingErnest
Copy link
Member

@ezatterin While waiting for the new release which hopefully has this fixed you may always decide to not crop the images when using %matplotlib inline via

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

in IPython or Jupyter.

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