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?

deadly
  • 1,194
  • 14
  • 24
tksy
  • 3,429
  • 17
  • 56
  • 61

1 Answers1

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.

Seth
  • 45,033
  • 10
  • 85
  • 120