Clear Filters
Clear Filters

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

3 views (last 30 days)
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.
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])
hold on

Accepted Answer

DGM on 5 Jan 2022
Edited: DGM on 5 Jan 2022
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.
X = x(11:22,11:22,1);
Y = y(11:22,11:22,1);
hold on
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.
hold on
shading interp
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:
muhammad choudhry
muhammad choudhry on 6 Jan 2022
quiverC2D(X, Y, U, V, 10); that worked as well! cheers thanks alot for your time and effort
DGM on 6 Jan 2022
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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!