I am trying to draw contour lines (elevation) associated with x and y coordinates. I have read examples here on how you draw contours on Matplotlib when z is defined by x and y but how can I draw contour lines that are independent of x and y?
This is my code:
import numpy as np
import matplotlib.pyplot as plt
data = [(0, 200, 140), (100, 430, 260), (800, 340, 320), (250, 110, 430), (290, 40, 100), (590, 35, 180)]
x = np.arange(0, 900, 20)
y = np.arange(0, 500, 20)
X, Y = np.meshgrid(x, y)
Z = [i[2] for i in data]
Z = np.array(Z)
plt.figure()
plt.contour(X, Y, Z)
plt.show()
I get an error "TypeError: Input z must be a 2D array."
This is the first time I am trying to draw contour lines and I appreciate any help on this.