Skip to content

missing imshow() subplots when using tight_layout() #4976

@douglase

Description

@douglase

Hello, I've found an unexpected behavior when I make grids of subplots with imshow and tight_layout the second to last plot is missing, for example:

import numpy as np
import matplotlib.pyplot as plt
plt.figure()
for i in range(16):
    ax= plt.subplot(4,4 ,i+1)
    im=ax.imshow(np.random.normal(size=100).reshape([10,10]))
    plt.tight_layout()
    plt.title(i)
plt.savefig("imshow_4x4.png")

generates:
imshow_4x4
Whereas the same loop with pcolor works:

import numpy as np
import matplotlib.pyplot as plt
plt.figure()
for i in range(16):
    ax= plt.subplot(4,4 ,i+1)
    im=ax.pcolor(np.random.normal(size=100).reshape([10,10]))
    plt.tight_layout()
    plt.title(i)
plt.savefig("pcolor_4x4.png")

gives:
pcolor_4x4

If I omit the tight_layout() call from the first example it works:
imshow_nottight_4x4

I'm using matplotlib 1.4.3 and numpy 1.9.2 in Anaconda 2.2.0.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions