Skip to content

Dimensions sanity check in axes_rgb swaps x and y of shape when checking, prevents use with non-square images. #7810

Closed
@sweeneytr

Description

@sweeneytr

Bug report

Bug summary

MatPlotLib axes_rgb cannot plot images of non-square dimensions, error in checking dimensions of red, green, and blue channels. Line 206 of mpl_toolkits.axes_grid1.axes_rgb.py erroneously swaps nx and ny.

Code for reproduction

  • A minimum code snippet required to reproduce the bug, also minimizing the number of dependencies required
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes

r = np.zeros((40, 100))
g = np.zeros_like(r)
b = np.zeros_like(r)

fig = plt.figure(2)
ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8])
ax.imshow_rgb(r, g, b)
plt.show()

Actual outcome

Python 2.7.12 |Anaconda 4.2.0 (64-bit)| (default, Jun 29 2016, 11:07:13) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes
>>>
>>> r = np.zeros((40, 100))
>>> g = np.zeros_like(r)
>>> b = np.zeros_like(r)
>>>
>>> fig = plt.figure(2)
>>> ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8])
>>> ax.imshow_rgb(r, g, b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Anaconda2\lib\site-packages\mpl_toolkits\axes_grid1\axes_rgb.py", line 211, in imshow_rgb
    ''.format(r.shape, g.shape, b.shape))
ValueError: Input shapes do not match.
r.shape = (40L, 100L)
g.shape = (40L, 100L)
b.shape = (40L, 100L)

Expected outcome

figure_2

Matplotlib version

  • 1.5.3, Python 2.7.12 :: Anaconda 4.2.0 (64-bit), Windows
  • Anaconda2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions