I'm trying to take an array on numpy, add a line of code, append it to the array, and then reshape the entire array back to the translated r. While I'm attempting to use plt.imshow to display it again, it keeps saying that the "total size of new array must be unchanged". Is there a better way to get around this?
z = np.array([[[23] * ncols]*nrows]).reshape(nrows, ncols)
for j in range(0,1):
for i in range(0,ncols):
np.append(z, [23])
np.reshape(z, nrows+1,ncols)
plt.imshow(z, interpolation='none', cmap=cm.gist_rainbow)
In addition, what if I iterate j from nrows to ncols? Are there specific edits that would need to happen other than just multiplying both by nrows and ncols?
EDIT: I tried reshaping with
np.reshape(z, nrows+2, ncols)
which works; however, when doing it with a range from 0 to 100 to check differences, the program takes forever and doesn't actually display new values. Are there better ways to deal with this?