How to plot fewer arrows and increase their size on a quiver plot that is merged over another field?
64 次查看(过去 30 天)
显示 更早的评论
I am merging 3 fields together (land/ocean, pressure field and velocity field).
I manage to align all the fields together but I can't find a way to reduce the number of arrows I am plotting on my quiver plot. I also want to increase the size of my arrows. When I tried to plot only 1/4 of the quiver's arrows, the quiver plot disappeared. See the commented line above.
I have attached my data as "data2.mat".
Here is my code:
load('data2.mat');
figure(1)
ax1 = axes;
pcolor(Land);
axis ij;
axis equal;
box on;
axis off;
shading flat;
ax2 = axes;
hold on;
pcolor(XERAmat,YERAmat, mslpPosMask);
contour(XERAmat,YERAmat, mslpPosMask,'k','LevelList',...
min(mslpPosMask,[],'all') - rem(min(mslpPosMask,[],'all'),1):1:...
max(mslpPosMask,[],'all') + (1 - rem(max(mslpPosMask,[],'all'),1)),'ShowText','on');
axis ij;
axis equal;
box on;
axis off;
shading flat;
ax3 = axes;
id = 4 ; % plot every 4th value
h2 = quiver(Upos,Vpos,'k');
%I try to plot fewers arrows and increase the size of the arrows
%h2 = quiver(Upos(1:id:end,1:id:end),Vpos(1:id:end,1:id:end),'k');
set(h2,'AutoScale','on', 'AutoScaleFactor', 5)
axis ij;
axis equal;
box on;
axis off;
shading flat;
%%Link axes together
linkaxes([ax1,ax2,ax3])
%%Hide the top axes
ax2.Visible = 'off';
ax2.XTick = [];
ax2.YTick = [];
%%Give each one its own colormap
colormap(ax1,cmap)
colormap(ax2,'parula')
%%Then add colorbars and get everything lined up
cb2 = colorbar(ax2,'Position',[0.8 0.11 0.05 0.815]);
ylabel(cb2,'sea level pressure (hPa)','Fontsize',18);
xlim([110 270]);
ylim([70 260]);
My actual figure:
I want my quiver plot to look more something like this:
Thank you
0 个评论
回答(1 个)
MJFcoNaN
2022-4-7
编辑:MJFcoNaN
2022-4-7
You may try this code:
id = 8 ; % plot every 4th value
ScaleFactor = 10;
Upos0 = Upos;
Vpos0 = Vpos;
Upos = NaN(size(Upos0));
Vpos = NaN(size(Vpos0));
Upos(1:id:end, 1:id:end)=Upos0(1:id:end, 1:id:end);
Vpos(1:id:end, 1:id:end)=Vpos0(1:id:end, 1:id:end);
h2 = quiver(Upos,Vpos,'k');
%I try to plot fewers arrows and increase the size of the arrows
%h2 = quiver(Upos(1:id:end,1:id:end),Vpos(1:id:end,1:id:end),'k');
set(h2,'AutoScale','on', 'AutoScaleFactor', ScaleFactor)
3 个评论
MJFcoNaN
2022-4-7
Sorry I forgot a comma...It should be:
Upos(1:id:end, 1:id:end)=Upos0(1:id:end, 1:id:end);
Vpos(1:id:end, 1:id:end)=Vpos0(1:id:end, 1:id:end);
另请参阅
类别
在 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!