How can I place a quiver plot on top of a surface plot?
3 次查看(过去 30 天)
显示 更早的评论
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
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 个评论
更多回答(0 个)
另请参阅
类别
在 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!