我有以下代码:
def plotter(x,y,w,h,n,list1):
randomList = randFunc(list1,x,y,w,h,n)
xlist = np.arange(2/(2*n),w,2/n)
ylist = np.arange(2/(2*n),h,2/n)
X,Y = np.meshgrid(xlist,ylist)
print(X)
randomList = randomList[['x','y']].values.tolist()
randomList = np.array(randomList)
z = []
for i in randomList:
z.append(q_func(i[0],i[1]))
z = np.array(z)
z = np.reshape(z,(n,n))
fig,ax2 = plt.subplots(1)
ax2.pcolormesh(Y,X,z)
代码输出代表表面的彩色网格,但是我想创建一个交互式滑块来更改n的值,并将更新图形以反映此更改。我该怎么办?