Matshow/imshow changes layout in matplotlib >= 3.3
See original GitHub issueDescription
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):
Actual behavior: The matshow command changes the layout:
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)
Proplot version
0.6.4
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Figure size/aspect for projections is not working anymore with ...
I think it is coming from the last version of Matplotlib 3.3. Here is the problem with a random ... Matshow/imshow changes layout...
Read more >Tight Layout guide — Matplotlib 3.6.2 documentation
In matplotlib, the location of axes (including subplots) are specified in normalized figure coordinates. It can happen that your axis labels or titles...
Read more >Constrained Layout Guide — Matplotlib 3.6.2 documentation
How to use constrained-layout to fit plots within your figure cleanly. ... Note in the below how the space at the edges doesn't...
Read more >Customizing Figure Layouts Using GridSpec and ... - Matplotlib
Specifies the geometry of the grid that a subplot will be placed. The number of rows and number of columns of the grid...
Read more >API Changes — Matplotlib 3.3.1 documentation
The behavior of both has been changed to ignore the width of the title and xlabel and the height of the ylabel in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@lukelbd Thanks for fixing this! For the sake of completeness,
git bisect
is a git feature for efficiently finding the commit that introduced a certain bug. It can save a lot of time 😃. See https://git-scm.com/docs/git-bisect for a nice introductionEating my words – it was e7f76fa (I have no idea what
git bisect
is but evidently I should learn). In matplotlib 3.3+ they translateaspect='equal'
toaspect=1
(these are synonyms since here “1” is in data units) but I confused matplotlib’s convention of data-units “aspect” with proplot’s convention of physical-units “aspect”. So this otherwise innocuous change caused the whole algorithm to fail.Now fixed by: 124ea3f