2013-07-15 25 views
0

我有一個滑塊條,它給出了要繪製的CSV文件的行。滑桿功能正常,並將返回正確的值。但是,我無法將值顯示在圖上。有兩件事情繪製了散點圖(4點)和插值曲面。散點圖按預期顯示。這是更新代碼:更新Matplotlib中的2D表面

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
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 

也沒有理由調整軸,如果他們保持相同的所有數據