# How can I place a quiver plot on top of a triangular surface (trisurf) plot?

9 ビュー (過去 30 日間)
Ravindu Lokuliyana 2019 年 8 月 28 日
コメント済み: Ravindu Lokuliyana 2019 年 8 月 29 日
Hi there,
I have plotted wave heights on an unstructured triagngular surface and added wave directions using quiver function.
Since these two plots are in two different planes, the final figure shows as attached image (Fig01.png).
Hereby attached the used code (Test_case.zip/Combine_Hsig_DIR_V1.m) with all relevent files.
Can anyone help me to place the quiver plot on top of the triangular surface?
Following mention the last part of the code.
elefile =[basename '.ele'];
fid = fopen(elefile); % load TRIANGLE element based connectivity file
[nelem] = fscanf(fid,'%i',[1 3]); % get number of triangles
ncol = 4 + nelem(3); % specify number of columns in elefile
tri = fscanf(fid,'%i',[ncol nelem(1)])'; % get connectivity table
z = eval([wavepar]); % get wave parameter
trisurf(tri(:,2:4),Xp,Yp,z); % make plot using trisurf
view(0,90);shading interp; % make 2D view and smooth plot
colormap(jet);colorbar;axis equal % include colorbar and equal axes
hold on;
hd = quiver(Xp,Yp,Hs_x,Hs_y,'color','k'); % plot directions
% set(hd, 'ZData', ones(size(get(hd, 'XData'))) * 999); % set quivers into top plane
BR,
Ravi

サインインしてコメントする。

### 採用された回答

KSSV 2019 年 8 月 29 日
USe 2D plot:
patch('faces',tri(:,2:4),'vertices',[Xp' Yp'],'facevertexcdata',z','facecolor','interp','edgecolor','none') ;
colormap(jet);colorbar;axis equal % include colorbar and equal axes
hold on;
quiver(Xp,Yp,Hs_x,Hs_y,'color','k'); % plot directions
If you want a 3D plot...you can use quiver3.
##### 1 件のコメント表示非表示 なし
Ravindu Lokuliyana 2019 年 8 月 29 日
It works perfectly fine. Thanks a lot.

サインインしてコメントする。

### Community Treasure Hunt

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

Start Hunting!

Translated by