Skip to content

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

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
sweeneytr opened this issue Jan 12, 2017 · 1 comment
Milestone

Comments

@sweeneytr
Copy link

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
@anntzer
Copy link
Contributor

anntzer commented Jan 16, 2017

Closed by #7826.

@anntzer anntzer closed this as completed Jan 16, 2017
@QuLogic QuLogic added this to the 2.0.1 (next bug fix release) milestone Jan 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants