필터 지우기
필터 지우기

How to plot fewer arrows and increase their size on a quiver plot that is merged over another field?

조회 수: 81 (최근 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

답변 (1개)

MJFcoNaN
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
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);
A LL
A LL 2022년 4월 7일
I ended up converting everthing on a lat/lon grid and using quivermc instead of quiver. Thank you for your time.

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

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by