Superimpose a quiver plot on top of a picture

Hi,
I want to superimpose vector field on top of a TIFF figure!! my vector fields are in '.struct' format, but apparently the vectors are always appear below the figure!! Does anyone know why this happen? & how to superimpose a quiver plot onto a figure?! Here is my code: close all clear all
U=load('VelU - 5m1p2s1.mat');
W=load('VelW - 5m1p2s1.mat')
img = imread('fc2_save_2014-11-17-213936-0000.tif');
imagesc(img);
hold on;
X = U(1,1).x(20:1:64,20:1:64);
Y = U(1,1).y(20:1:64,20:1:64);
Velu = U(1,1).u(20:1:64,20:1:64);
Velw = W(1,1).w(20:1:64,20:1:64);
quiver(X,Y,Velu,Velw, 'y','linewidth',2);

 Respuesta aceptada

Chad Greene
Chad Greene el 31 de Dic. de 2014
Editada: Chad Greene el 31 de Dic. de 2014
Your image is plotted with x and y in units of pixels (from 1 to 1024), but your quiver plot spans the range 0.15 to 0.45. Replace your imagesc line with
imagesc(unique(X),unique(Y),img);

2 comentarios

soroush
soroush el 31 de Dic. de 2014
Yes, changing the image range make it works finally! Thank you Chad!
Chad Greene
Chad Greene el 31 de Dic. de 2014
You should verify that those pixels are properly registered. That is, make sure that each pixel in img is assigned to the proper x and y coordinates.

Iniciar sesión para comentar.

Más respuestas (1)

Chad Greene
Chad Greene el 31 de Dic. de 2014
Sometimes stacking gets a little confused, especially depending on the renderer and Matlab distribution. You can try
h = quiver(X,Y,Velu,Velw, 'y','linewidth',2);
uistack(h,'top')
or place the arrows at a higher z value with quiver3 like this:
quiver3(X,Y,ones(Velu),Velu,Velw,zeros(Velu) 'y','linewidth',2);

1 comentario

Oops, that should be
quiver3(X,Y,ones(size(Velu)),Velu,Velw,zeros(size(Velu)) 'y','linewidth',2);

Iniciar sesión para comentar.

Categorías

Más información sobre Vector Fields en Centro de ayuda y File Exchange.

Preguntada:

el 31 de Dic. de 2014

Comentada:

el 31 de Dic. de 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by