我有一个滑动条,用于绘制CSV文件的行。滑块功能正常,将返回正确的值。但是,我无法将值显示在图表上。绘制散点图(有4个点)和插值曲面有两点。散点图按预期显示。这是更新代码:
def update (val):
ax.clear()
val=int(val)
new=a[val]
canvas1.blit(axsigma.bbox)
ax.scatter(x, y, marker='o', s=256, lw=.1)
xi, yi = np.mgrid[x.min():x.max():500j, y.min():y.max():500j]
newi = griddata(x,y,new,xi,yi, interp='nn')
CS = plt.contourf(xi,yi,newi,500,cmap='jet', vmax=5, vmin=0) ##This line should plot the new temperatures
ax.relim()
ax.autoscale_view(True,True,True)
任何建议都将不胜感激。提前谢谢!
答案 0 :(得分:0)
def update (val):
ax.clear()
val=int(val)
new=a[val]
canvas1.blit(axsigma.bbox)
xi, yi = np.mgrid[x.min():x.max():500j, y.min():y.max():500j]
newi = griddata(x,y,new,xi,yi, interp='nn')
CS = ax.contourf(xi,yi,newi,500,cmap='jet', vmax=M, vmin=m) ##change plt to ax
ax.scatter(x, y, marker='x', c='k', s=36) ## move to end so scatter is on top of surface
如果轴对所有数据保持不变,也没有理由调整轴的大小