def GridPlot(vf, sliceIdx=None, dim='z', every=1, isVF=True, color='g', plotBase=True, colorbase='#A0A0FF'): sliceArr = np.squeeze(common.ExtractSliceArrVF(vf, sliceIdx, dim)) sz = sliceArr.shape hID = np.mgrid[0:sz[0], 0:sz[1]] d1 = np.squeeze(hID[1, ::every, ::every]) d2 = np.squeeze(hID[0, ::every, ::every]) sliceArr = sliceArr[::every, ::every, :] if plotBase: plt.plot(d1, d2, colorbase) plt.hold(True) plt.plot(d1.T, d2.T, colorbase) if not isVF: d1 = np.zeros(d1.shape) d2 = np.zeros(d2.shape) plt.plot(d1+np.squeeze(sliceArr[:,:,1]), d2+np.squeeze(sliceArr[:,:,0]), color) plt.hold(True) plt.plot((d1+np.squeeze(sliceArr[:,:,1])).T, (d2+np.squeeze(sliceArr[:,:,0])).T, color) plt.hold(False) # change axes to match image axes if not plt.gca().yaxis_inverted(): plt.gca().invert_yaxis() # force redraw plt.draw()
def MyQuiver(vf, sliceIdx=None, dim='z',every=1,thresh=None,scaleArrows=None,arrowCol='r',lineWidth=None, width=None): sliceArr = common.ExtractSliceArrVF(vf, sliceIdx, dim) if dim=='z': vy = np.squeeze(sliceArr[:,:,0]) vx = np.squeeze(sliceArr[:,:,1]) elif dim=='x': vy = np.squeeze(sliceArr[:,:,1]) vx = np.squeeze(sliceArr[:,:,2]) elif dim=='y': vy = np.squeeze(sliceArr[:,:,0]) vx = np.squeeze(sliceArr[:,:,2]) vxshow = np.zeros(np.shape(vx)) vyshow = np.zeros(np.shape(vy)) vxshow[::every,::every] = vx[::every,::every] vyshow[::every,::every] = vy[::every,::every] valindex = np.zeros(np.shape(vx),dtype=bool) valindex[::every,::every] = True if thresh is not None: valindex[(vx**2+vy**2)<thresh] = False #gridX, gridY = np.meshgrid(range(np.shape(vx)[0]),range(np.shape(vx)[1]-1,-1,-1)) gridX, gridY = np.meshgrid(range(np.shape(vx)[0]),range(np.shape(vx)[1])) quiverhandle = plt.quiver(gridX[valindex],gridY[valindex],vx[valindex],vy[valindex],scale=scaleArrows,color=arrowCol,linewidth=lineWidth,width=width,zorder=4) # change axes to match image axes plt.gca().invert_yaxis() # force redraw plt.draw()
def Quiver(vf, sliceIdx=None, dim='z'): sliceArr = common.ExtractSliceArrVF(vf, sliceIdx, dim) plt.quiver(np.squeeze(sliceArr[:,:,0]).T, np.squeeze(sliceArr[:,:,1]).T, scale=None) # change axes to match image axes if not plt.gca().yaxis_inverted(): plt.gca().invert_yaxis() # force redraw plt.draw()