2

I am trying to generate a 3D histogram using python. I tried the following code but I am getting an error too many values to unpack.

from matplotlib import pyplot
import pylab
from mpl_toolkits.mplot3d import Axes3D
import numpy    

fig = pylab.figure()
ax = Axes3D(fig)

data_filename = 'C:\csvfiles\luxury.txt'

data_file = numpy.loadtxt(data_filename, delimiter=',')

X = data_file[:,1]
Y = data_file[:,2]
Z = data_file[:,3]

ax.hist(X, Y, Z)
pyplot.show()

What am I doing wrong?

0

1 Answer 1

3

"Too many values to unpack" happens when you do something like this:

(a, b) = (1, 2, 3)

That is, not enough variables on the left to accept all of the values on the right of the =.

Update:

Try: ax.hist( (X, Y, Z) )

The hist function wants a tuple as the first argument.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.