I have three arrays such as follows:
x = np.array([x1,x2,....x400])
y = np.array([y1,y2,....y400])
z = np.array([z1,z2,....z400])
The x and y values define a 2d plane with a length and depth of 400 values each and z is the color (intensity) calculated from a function using x and y values.
I would like to plot a 2d contour plot and I have tried the following based on the post in here :
x_, y_ = np.meshgrid(x, y)
z_grid = np.array(z).reshape(400,400)
fig = plt.figure()
ax1 = plt.contourf(x_,y_,z_grid)
plt.show()
However, I am receiving the following error:
cannot reshape array of size 400 into shape (400,400)
What is the correct way to plot this 2D contour?