Skip to content

Matshow/imshow changes layout in matplotlib >= 3.3 #235

@matthias-k

Description

@matthias-k

Description

I set up a subplots layout the way I need it for my figure and the subplots look good. But as soon as I start filling the axes with image-data using matshow or imshow, the layout is completely changed. It appears, the axes change their aspect ratio to one, resulting in large margins in the final plot.

Steps to reproduce

import proplot as plot
import numpy as np

f, axes = plot.subplots(nrows=2, ncols=5, aspect=4/3, wspace='3mm', hspace='3mm')
axes[0].matshow(np.random.randn(3,4))

Expected behavior: I expect to see a nicely aligned grid of axes with the given aspect ratio, the first axes should be completely filled with the random data, roughly like this (except for the missing data):
Screenshot_20201115_001856

Actual behavior: The matshow command changes the layout:
Screenshot_20201115_002011

Equivalent steps in matplotlib

Not sure whether this applies here, but with the matplotlib subplots, the layout is not changed after the first matshow.

import matplotlib.pyplot as plt
import numpy as np

f, axes = plt.subplots(2, 5, figsize=(4*5, 3*2))
axes[0, 0].matshow(np.random.randn(3,4))
f.subplots_adjust(hspace=0.1, wspace=0.1, left=0.02, right=0.98, top=0.98, bottom=0.02)

Screenshot_20201115_002427

Proplot version

0.6.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions