필터 지우기
필터 지우기

Why the colour bar values are not representing the vectors on the plot?

조회 수: 4 (최근 30일)
Hi please see the attached image I am trying to use the colour bar to represent the U and V values from the graph but it is not representing it. can you guys guide me how to process it. Below is my current code.
Code:
files = { 'F:\3-PIV_Experimental_Data\Outlet_110\Data_LaserSheet_D\Data_PIV\Data_Vector\Run 13-56-31.Adaptive PIV.6tvk0mbp\Export.6tvk0mbp.000000.csv'; ...
'F:\3-PIV_Experimental_Data\Outlet_110\Data_LaserSheet_B\Data_PIV\Data_Vector\Run 17-19-03.Adaptive PIV.6ul4ynyv\Export.6ul4ynyv.000000.csv'; ...
'F:\3-PIV_Experimental_Data\Outlet_110\Data_LaserSheet_B\Data_PIV\Data_Vector\Run 17-19-03.Adaptive PIV.6ul4ynyv\Export.6ul4ynyv.000000.csv'; ...
'F:\3-PIV_Experimental_Data\Outlet_110\Data_LaserSheet_A\Data_PIV\Data_Vector\Run 12-45-51.Adaptive PIV.6tskdx6a\Export.6tskdx6a.000000.csv'};
for i = 1:numel(files)
a = readtable(files{i});
X = a{:,5}/1000;
Y = a{:,6}/1000;
U = a{:,9};
V = a{:,10};
quiver(X, Y, U, V, 10);
xlim([0.1 0.4])
ylim([0.1 0.4])
colorbar('AxisLocation','in')
hold on
end
legend('DataLaserSheet-D','DataLaserSheet-C','DataLaserSheet-B','DataLaserSheet-A')

채택된 답변

DGM
DGM 2022년 1월 5일
편집: DGM 2022년 1월 5일
Quiver plots and line plots do not use the colormap used by colorbar. You have to explicitly set both the axes 'colororder' and 'colormap' properties to the same map.
load('wind','x','y','u','v')
X = x(11:22,11:22,1);
Y = y(11:22,11:22,1);
hold on
quiver(X,Y,u(11:22,11:22,1),v(11:22,11:22,1));
quiver(X,Y,u(11:22,11:22,2),v(11:22,11:22,2));
quiver(X,Y,u(11:22,11:22,3),v(11:22,11:22,3));
quiver(X,Y,u(11:22,11:22,4),v(11:22,11:22,4));
colormap(get(gca,'colororder'))
colorbar
That said, that's really what the legend is for. In this case, the colorbar scale has no clear meaning.
Still, I'm not sure if that's what you're asking for. "I am trying to use the colour bar to represent the U and V values" might mean that you're trying to describe the vector fields using some solid color map (like pcolor() or something). If that's the case, you'll have to actually do that.
figure
hold on
pcolor(X,Y,hypot(u(11:22,11:22,1),v(11:22,11:22,1)));
quiver(X,Y,u(11:22,11:22,1),v(11:22,11:22,1));
shading interp
colormap(gray(256))
colorbar
Note that I only plotted one quiver plot and the pcolor() plot shows only the vector magnitude. Trying to put more things into the same plot should raise the question of how they're expected to be represented clearly.
If you want to represent the vector field (both components) with pcolor(), then you might want to look at this discussion:
  댓글 수: 5
muhammad choudhry
muhammad choudhry 2022년 1월 6일
quiverC2D(X, Y, U, V, 10); that worked as well! cheers thanks alot for your time and effort
DGM
DGM 2022년 1월 6일
I'm glad that tool worked out. I was worried you might have issues with such a large dataset. Getting good visualization out of quiver plots is kind of maddening, as you can see.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Blue에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by