Hey,

I am having issues with some code which keeps coming up with an error. I am creating a river erosion simulator with matplotlib embedded into tkinter. The error message is attached below. I believe this is due to only an array being foind, not a 2D, but I am not so sure. I can share the code below which I believe to be causing the problem.

I would appreciate any help, as this is my first time using Matplotlib.

Code:

def generatepoints(x, y, point1, point2):

squareroot1 = np.sqrt((point1[0] - x)**2 + (point1[1] - y)**2)#cannot chang

#e the **2

arctangent1 = np.arctan2(point1[0] - x, point1[1] - y)

squareroot2 = np.sqrt((x - point2[0])**2 + (y -point2[1])**2)

arctangent2 = np.arctan2(x - point2[0], y - point2[1])

z = -(2 * (np.exp((squareroot1 / 5)**2) - 1) * 30. * np.cos(7. * arctangent1) +
(np.exp((squareroot2 / 5) 2) - 1) * 30. * np.cos(11. * arctangent2) +
0.7 * (x2 + y**2))

return (np.max(z) - z) / (np.max(z) - np.min(z))#normalisation of the values error related to here?

no_of_angles = 100 #smoothed out edge, non-clunky

radiusofcircle = 10

whitecircle = 0 #removed unnecesary white circle in the middle

radii = np.linspace(whitecircle, 0.95, radiusofcircle)

angles = np.linspace(0, 2 * np.pi, no_of_angles, endpoint=False)

angles = np.repeat(angles[…, np.newaxis], radiusofcircle, axis=1)

angles[:, 1::2] += np.pi / no_of_angles #this is the grid behind I think?

x = (radii * np.cos(angles)).flatten()

y = (radii * np.sin(angles)).flatten()

z = generatepoints(x, y, point1, point2)

triang = tri.Triangulation(x, y)

triang.set_mask(np.hypot(x[triang.triangles].mean(axis=1),

y[triang.triangles].mean(axis=1))

< radiusofcircle)

refiner = tri.UniformTriRefiner(triang)

tri_refi, z_test_refi = refiner.refine_field(z, subdiv=3)