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

3 vues (au cours des 30 derniers jours)
MathWorks Support Team
MathWorks Support Team le 22 Août 2013
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.

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 22 Août 2013
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

Plus de réponses (0)

Catégories

En savoir plus sur Vector Fields dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by