change the following:
# Calculate the mean
v_z = (numpy.apply_over_axes(numpy.mean,potential[:,:,:],[0,1]).flatten() * potential[:,:,:].unit()).inUnitsOf(eV)
# determine the z values
dX, dY, dZ = potential.volumeElement()
dz = numpy.linalg.norm(dZ.inUnitsOf(Ang))
z = dz *numpy.arange(potential.shape()[2])
plot1.addData([z,v_z])
into
# Calculate the mean
v_x = (numpy.apply_over_axes(numpy.mean,potential[:,:,:],[1,2]).flatten() * potential[:,:,:].unit()).inUnitsOf(eV)
# determine the z values
dX, dY, dZ = potential.volumeElement()
dx = numpy.linalg.norm(dX.inUnitsOf(Ang))
x = dx *numpy.arange(potential.shape()[0])
plot1.addData([x,v_x])