Why the colour bar values are not representing the vectors on the plot?
3 次查看(过去 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')
0 个评论
采纳的回答
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 个评论
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 Center 和 File Exchange 中查找有关 Vector Fields 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!