I am trying to plot some data and I am getting this error from the noted line. I googled the line but couldn't find any meaningful discussion on this issue. I am new to Python so trying to figure this stuff out as I go along.
pl.figure()
ax = pl.subplot(111)
ax.plot(Xk[:,0], Xk[:,1], '.')
ERROR=>>> twos = (y == 2).nonzero()[0]
for i in twos:
imagebox = OffsetImage(X[i,:].reshape(28,28))
location = Xk[i,0], Xk[i,1]
ab = AnnotationBbox(imagebox, location, boxcoords='data', pad=0.)
ax.add_artist(ab)
pl.show()
This is the error message
AttributeError: 'bool' object has no attribute 'nonzero'
Any clues, seems like y
may not be a comparable entity.
I am trying to massage code from a sample file to get my own stuff going so forgive if this is a bit redundant.
I do appreciate the help.