I've got a set of x values, y values and the corresponding z value at each (X,Y)
I'm trying to plot a contour plot in matplotlib but whenever I try to plot the contours I get the following error:-
TypeError: Input z must be 2D, not 1D
I don't understand how I'm supposed to input a 2D array of z values when I only have one value for each (x,y) point
Edit: Apologies for not including my code
x= [7.7, 7.7, 7.7, 7.7, 7.7, 6.7, 6.7, 6.7, 6.7, 6.7, 5.8, 5.8, 5.8, 5.8, 5.8, 4.8, 4.8, 4.8, 4.8, 4.8, 3.9, 3.9, 3.9, 3.9, 3.9, 2.9, 2.9, 2.9, 2.9, 2.9]
y= [3, 4, 5, 6, 7, 2, 4.5, 5, 6.7, 8, 3.2, 4.5, 5.5, 6, 7.5, 4.3, 8.5, 7, 6.4, 3.5, 2.4, 4.5, 6.8, 7.5, 8, 2.5, 4.3, 5.4, 7.6, 8.2]
z= [1, 1, 1, 1, 1, 1.5, 1.5, 1.5, 1.5, 1.5, 2, 2, 2, 2, 2, 2.5, 2.5, 2.5, 2.5, 2.5, 3, 3, 3, 3, 3, 3.5, 3.5, 3.5, 3.5, 3.5]
X, Y = np.meshgrid(x, y)
fig,ax=plt.subplots(1,1)
ax.plot(X,Y,color='green')
cp = ax.contourf(X, Y, z)
fig.colorbar(cp) # Add a colorbar to a plot
plt.show()