I have been trying to run the provided code to make a color map.
The data set has x
and y
coordinates, and each coordinate is to have it's own color.
However, when I run the code, I get an error saying setting an array element with a sequence
.
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from math import pi, sin
x, y, c = np.loadtxt('finaltheta.txt', unpack = True)
N = int(len(c)**0.5)
c = c.reshape(N,N)
plt.figure()
plt.imshow(c, extent = (np.amin(x), np.amax(x), np.amin(y), np.amax(y)), cmap = cm.binary, vmin = 0.0, vmax = 1.0)
cbar = plt.colorbar()
plt.show()
I have deduced that the error is streaming from the np.loadtxt
line.
finaltheta.txt
so I can use for my test. – flamenco yesterday