Shifting a quiver plot of image data to the origin and decreasing the density of the vectors in the quiver

1 次查看(过去 30 天)
Currently, after processing a lot of data the image is in the form of a 86x85x8 double. The file I use is called T3C3BFS10HZ
Here is the image of the quiver and the contour :
Here is the section of code where I plot both the contour or quiver :
figure (2)
origin = [0,0]
contour(flip(sqrt(T3C3BFS10dat(1).data(:,:,4)).^2 + (T3C3BFS10dat(1).data(:,:,5)).^2 ...
+ (T3C3BFS10dat(1).data(:,:,6)).^2));
colorbar()
hold on
% xval = abs(0-T3C3BFS10dat(1).data(1,1,1));
% yval = abs(0-T3C3BFS10dat(1).data(1,1,2));
% sizing = size(T3C3BFS10dat(1).data);
% for i = 1:sizing(1)
% for j = 1:sizing(2)
% xpix(i,j) = T3C3BFS10dat(1).data(i,j,1)+xval;
% ypix(i,j) = T3C3BFS10dat(1).data(i,j,2)+yval
% end
% end
% quiver(T3C3BFS10dat(1).data(:,:,1), T3C3BFS10dat(1).data(:,:,2), ...
% T3C3BFS10dat(1).data(:,:,4), T3C3BFS10dat(1).data(:,:,5))
quiver(T3C3BFS10dat(1).data(:,:,1), T3C3BFS10dat(1).data(:,:,2),T3C3BFS10dat(1).data(:,:,4),T3C3BFS10dat(1).data(:,:,5))
hold off
As you can see I had to flip the contour plot to get it in the correct direction. I then am trying to move the blue giver up and to the right to overlap the contour. I tried doing this by calulating the distance of the 1st point from (0,0) then added that value to the entire double, but this is too computationally expensive and didn't finish in five minutes just for one image. From my undertstanding, I think it is doing this because the quiver is trying to plot according to the given x and y coordinates, but the contour is a magnitude and as such prefers to start at (0,0). While the specified axis for the quiver is technically correct it would be much more helpful to read if it began at the same place as the contour. To summarize I would like them to overlap where the contour plot is.
Ideally I am trying to make it look like this imagesc where 0,0 begins on the top left corner:
I also tried just making an array of new values adding the difference but the different data types of matrix and array prevents me from plotting the quiver that way.
I understand this is a lot. Thank you very much in advance. I have attached the datafile corresponding to this image below. I constructed the struct so that .data is where the image data is and the rest are just fields, velocity information etc.

采纳的回答

Jensen Lam
Jensen Lam 2024-5-10
I managed to relocate the countour plot to the quiver space by also specifying the pixels.
Additionally I also decreased the vectors by creating a sizing variable and then making it do every 5 vectors or so using the following. Hopefully this helps someone.
sc = 5;
figure (2)
origin = [0,0]
contourf(T3C3BFS10dat(1).data(:,:,1), T3C3BFS10dat(1).data(:,:,2), sqrt(T3C3BFS10dat(1).data(:,:,4)).^2 + (T3C3BFS10dat(1).data(:,:,5)).^2 ...
+ (T3C3BFS10dat(1).data(:,:,6)).^2);
colorbar()
colormap("gray")
hold on
sizing = size(T3C3BFS10dat(1).data);
quiver(T3C3BFS10dat(1).data(1:sc:sizing(1),1:sc:sizing(2),1), T3C3BFS10dat(1).data(1:sc:sizing(1),1:sc:sizing(2),2),T3C3BFS10dat(1).data(1:sc:sizing(1),1:sc:sizing(2),4),T3C3BFS10dat(1).data(1:sc:sizing(1),1:sc:sizing(2),5))
hold off

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Contour Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by