How can I place a quiver plot on top of a surface plot?

2 ビュー (過去 30 日間)
MathWorks Support Team
MathWorks Support Team 2013 年 8 月 22 日
When I place a quiver plot on a 2-D surface plot (pcolor), resizing or printing the figure window causes the quiver plot to disappear. I would like to place a quiver plot on top of a surface plot.

採用された回答

MathWorks Support Team
MathWorks Support Team 2013 年 8 月 22 日
The quiver plot disappears because both the surface plot and quiver plot are located in the XY-plane (Z = 0) and the renderer is set to 'painters'. You can avoid this issue by changing the renderer as follows:
set(gcf, 'renderer', 'zbuffer')
If you would like to keep the renderer to 'painters', you can place the surface plot at a -Z offset. For example:
xord = -2:.2:2;
yord = -2:.2:2;
[x,y] = meshgrid(xord,yord);
z = x .* exp(-x.^2 - y.^2);
[px,py] = gradient(z,.2,.2);
quiver(x,y,px,py)
hold on
h = pcolor(x,y,z);
set(h,'ZData',-1+zeros(size(z))) % Move the surface plot to Z = -1
colormap(gray)
shading interp

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVector Fields についてさらに検索

タグ

タグが未入力です。

製品

Community Treasure Hunt

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

Start Hunting!

Translated by