Skip to content
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

figaspect not working with numpy floats #5464

Closed
davidcortesortuno opened this issue Nov 11, 2015 · 1 comment
Closed

figaspect not working with numpy floats #5464

davidcortesortuno opened this issue Nov 11, 2015 · 1 comment
Assignees
Milestone

Comments

@davidcortesortuno
Copy link

If I try to use a numpy float as the input of the matplotlib.pyplot.figaspect function, I get an error.
This is the code

import numpy as np
import matplotlib.pyplot as plt

aspect = np.float64(2) / np.float64(1)
# print aspect
w, h = plt.figaspect(aspect)
fig = plt.figure(figsize=(w,h))
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])

with the Error

/usr/local/lib/python2.7/dist-packages/matplotlib/figure.pyc in figaspect(arg)
   1770     # Extract the aspect ratio of the array
   1771     if isarray:
-> 1772         nr, nc = arg.shape[:2]
   1773         arr_ratio = float(nr) / nc
   1774     else:

ValueError: need more than 0 values to unpack

If I convert aspect to a float, it works ok

@WeatherGod
Copy link
Member

Confirmed. Fix coming shortly.

On Wed, Nov 11, 2015 at 2:26 PM, David Ignacio Cortes <
notifications@github.com> wrote:

If I try to use a numpy float as the input of the
matplotlib.pyplot.figaspect function, I get an error.
This is the code

import numpy as np
import matplotlib.pyplot as plt

aspect = np.float64(2) / np.float64(1)

print aspect

w, h = plt.figaspect(aspect)
fig = plt.figure(figsize=(w,h))
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])

with the Error

/usr/local/lib/python2.7/dist-packages/matplotlib/figure.pyc in figaspect(arg)
1770 # Extract the aspect ratio of the array
1771 if isarray:
-> 1772 nr, nc = arg.shape[:2]
1773 arr_ratio = float(nr) / nc
1774 else:

ValueError: need more than 0 values to unpack

If I convert aspect to a float, it works ok


Reply to this email directly or view it on GitHub
#5464.

@mdboom mdboom added this to the Critical bugfix release (1.5.1) milestone Nov 11, 2015
tacaswell added a commit that referenced this issue Nov 18, 2015
FIX: Better test for isarray in figaspect(). Closes #5464.
tacaswell added a commit that referenced this issue Nov 18, 2015
FIX: Better test for isarray in figaspect(). Closes #5464.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants